From: Benno Schulenberg Date: Fri, 2 May 2025 12:22:41 +0000 (+0200) Subject: irqtop: use standard 'always/never' arguments instead of 'enable/disable' X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b3687403a35a20e304fbdfb6e345775a7c8ec57;p=thirdparty%2Futil-linux.git irqtop: use standard 'always/never' arguments instead of 'enable/disable' 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 Signed-off-by: Benno Schulenberg --- diff --git a/bash-completion/irqtop b/bash-completion/irqtop index 5faf122e5..0dd2f1981 100644 --- a/bash-completion/irqtop +++ b/bash-completion/irqtop @@ -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') diff --git a/sys-utils/irqtop.1.adoc b/sys-utils/irqtop.1.adoc index cf258d085..63675f076 100644 --- a/sys-utils/irqtop.1.adoc +++ b/sys-utils/irqtop.1.adoc @@ -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. diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c index 3dbd030e0..51e04ee85 100644 --- a/sys-utils/irqtop.c +++ b/sys-utils/irqtop.c @@ -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 whether to show the per-cpu stats (auto|enable|disable)\n"), stdout); + fputs(_(" -c, --cpu-stat whether to show the per-cpu stats (auto|never|always)\n"), stdout); fputs(_(" -C, --cpu-list show IRQs only for the specified cpus\n"), stdout); fputs(_(" -d, --delay 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': {