]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
irqtop: use standard 'always/never' arguments instead of 'enable/disable'
authorBenno Schulenberg <bensberg@telfort.nl>
Fri, 2 May 2025 12:22:41 +0000 (14:22 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 5 May 2025 08:45:15 +0000 (10:45 +0200)
Most other util-linux tools that accept the option argument "auto"
additionally accept "always" and "never", not "enable" / "disable".

So, make option --cpu-stat accept those standard words (besides the
deviant ones), and adjust the documentation to use the standard words.

Furthermore, make --cpu-stat accept also "on", "off", "yes", "no",
"1", and "0", to allow the user to use shorter words.  The per-CPU
stats can now be suppressed with a succinct: `irqtop -c0`.

CC: Zhenwei Pi <pizhenwei@bytedance.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
bash-completion/irqtop
sys-utils/irqtop.1.adoc
sys-utils/irqtop.c

index 5faf122e5a1e3ff2c68519aac6a1145efffc4779..0dd2f19819ccabe5587e324e145bd1ec967a2556 100644 (file)
@@ -9,7 +9,7 @@ _irqtop_module()
                        return 0
                        ;;
                '-c'|'--cpu-stat')
-                       COMPREPLY=( $(compgen -W "auto enable disable" -- $cur) )
+                       COMPREPLY=( $(compgen -W "auto enable disable always never" -- $cur) )
                        return 0
                        ;;
                '-C'|'--cpu-list')
index cf258d08532daba3601d4e719e20aa0b6686a610..63675f076b75e9e7b1363c055d19420f654499d5 100644 (file)
@@ -29,8 +29,10 @@ Specify which output columns to print. Use *--help* to get a list of all support
 Send the produced tables to stdout instead of to a static screen.
 This can be used for sending the output to other programs or to a file.
 
-*-c*, *--cpu-stat* _mode_::
-Show per-cpu statistics by specified mode. Available modes are: *auto*, *enable*, *disable*. The default option *auto* detects the width of window, then shows the per-cpu statistics if the width of window is large enough to show a full line of statistics.
+*-c*, *--cpu-stat* _when_::
+Whether to show the per-CPU statistics. Possible arguments are: *auto*, *never*, *always*.
+The default is *auto*: the per-CPU statistics are shown when the window is wide enough
+for the full list of CPUs.
 
 *-C*, *--cpu-list* _list_::
 Specify cpus in list format to show.
index 3dbd030e0b1ebac4ecc8c84a58300d8a3b2ab1de..51e04ee85ab0f70bb880c0ea4dd5766aecebd325 100644 (file)
@@ -307,7 +307,7 @@ static void __attribute__((__noreturn__)) usage(void)
 
        fputs(USAGE_OPTIONS, stdout);
        fputs(_(" -b, --batch            send tables to stdout, not to a static screen\n"), stdout);
-       fputs(_(" -c, --cpu-stat <mode>  whether to show the per-cpu stats (auto|enable|disable)\n"), stdout);
+       fputs(_(" -c, --cpu-stat <when>  whether to show the per-cpu stats (auto|never|always)\n"), stdout);
        fputs(_(" -C, --cpu-list <list>  show IRQs only for the specified cpus\n"), stdout);
        fputs(_(" -d, --delay <secs>     wait this number of seconds between updates\n"), stdout);
        fputs(_(" -J, --json             use JSON output format (implies --batch)\n"), stdout);
@@ -364,12 +364,11 @@ static void parse_args(   struct irqtop_ctl *ctl,
                case 'c':
                        if (!strcmp(optarg, "auto"))
                                ctl->cpustat_mode = IRQTOP_CPUSTAT_AUTO;
-                       else if (!strcmp(optarg, "enable"))
-                               ctl->cpustat_mode = IRQTOP_CPUSTAT_ENABLE;
-                       else if (!strcmp(optarg, "disable"))
-                               ctl->cpustat_mode = IRQTOP_CPUSTAT_DISABLE;
                        else
-                               errx(EXIT_FAILURE, _("unsupported mode '%s'"), optarg);
+                               ctl->cpustat_mode = IRQTOP_CPUSTAT_DISABLE - parse_switch(optarg,
+                                                       _("unsupported argument"), "yes", "no",
+                                                       "always", "never", "enable", "disable",
+                                                       "on", "off", "1", "0", NULL);
                        break;
                case 'C':
                        {