From c8aa5e526fc02c360b09718a7dcb5db1876dca05 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 12 Jun 2018 06:53:31 +0000 Subject: top(1): move command mapping to commands.c This eliminates the difficult to follow mapping of a string list. It moves numbers from "#define" into (more) debuggable enums. More generally, it follows the trend of moving more data into a more central mechanism. The help output is a little worse: " " is not rendered well, and there are duplicate entries, but that will be fixed in a followup. --- usr.bin/top/commands.c | 60 +++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'usr.bin/top/commands.c') diff --git a/usr.bin/top/commands.c b/usr.bin/top/commands.c index 716648f6af6b..a391a9ce9334 100644 --- a/usr.bin/top/commands.c +++ b/usr.bin/top/commands.c @@ -50,38 +50,38 @@ static int str_addarg(char *str, int len, char *arg, bool first); * either 'h' or '?'. */ -static const struct command all_commands[] = +const struct command all_commands[] = { - {'C', "toggle the displaying of weighted CPU percentage", false }, - {'d', "change number of displays to show", false}, - {'e', "list errors generated by last \"kill\" or \"renice\" command", false}, - {'H', "toggle the displaying of threads", false}, - {'h', "show this help text", true}, - {'?', "show this help text", true}, - {'i', "toggle the displaying of idle processes", false}, - {'I', "toggle the displaying of idle processes", false}, - {'j', "toggle the displaying of jail ID", false}, - {'J', "display processes for only one jail (+ selects all jails)", false}, - {'k', "kill processes; send a signal to a list of processes", false}, - {'q', "quit" , true}, - {'m', "toggle the display between 'cpu' and 'io' modes", false}, - {'n', "change number of processes to display", false}, - {'#', "change number of processes to display", false}, - {'o', "specify the sort order", false}, - {'p', "display one process (+ selects all processes)", false}, - {'P', "toggle the displaying of per-CPU statistics", false}, - {'r', "renice a process", false}, - {'s', "change number of seconds to delay between updates", false}, - {'S', "toggle the displaying of system processes", false}, - {'a', "toggle the displaying of process titles", false}, - {'T', "toggle the displaying of thread IDs", false}, - {'t', "toggle the display of this process", false}, - {'u', "display processes for only one user (+ selects all users)", false}, - {'w', "toggle the display of swap use for each process", false}, - {'z', "toggle the displaying of the system idle process", false }, - {0, NULL, true} + {'C', "toggle the displaying of weighted CPU percentage", false, CMD_wcputog}, + {'d', "change number of displays to show", false, CMD_displays}, + {'e', "list errors generated by last \"kill\" or \"renice\" command", false, CMD_errors}, + {'H', "toggle the displaying of threads", false, CMD_thrtog}, + {'h', "show this help text", true, CMD_help}, + {'?', "show this help text", true, CMD_help}, + {'i', "toggle the displaying of idle processes", false, CMD_idletog}, + {'I', "toggle the displaying of idle processes", false, CMD_idletog}, + {'j', "toggle the displaying of jail ID", false, CMD_jidtog}, + {'J', "display processes for only one jail (+ selects all jails)", false, CMD_jail}, + {'k', "kill processes; send a signal to a list of processes", false, CMD_kill}, + {'q', "quit" , true, CMD_quit}, + {'m', "toggle the display between 'cpu' and 'io' modes", false, CMD_viewtog}, + {'n', "change number of processes to display", false, CMD_number}, + {'#', "change number of processes to display", false, CMD_number}, + {'o', "specify the sort order", false, CMD_order}, + {'p', "display one process (+ selects all processes)", false, CMD_pid}, + {'P', "toggle the displaying of per-CPU statistics", false, CMD_pcputog}, + {'r', "renice a process", false, CMD_renice}, + {'s', "change number of seconds to delay between updates", false, CMD_delay}, + {'S', "toggle the displaying of system processes", false, CMD_viewsys}, + {'a', "toggle the displaying of process titles", false, CMD_showargs}, + {'T', "toggle the displaying of thread IDs", false, CMD_toggletid}, + {'t', "toggle the display of this process", false, CMD_selftog}, + {'u', "display processes for only one user (+ selects all users)", false, CMD_user}, + {'w', "toggle the display of swap use for each process", false, CMD_swaptog}, + {'z', "toggle the displaying of the system idle process", false, CMD_kidletog}, + {' ', "update the display", false, CMD_update}, + {0, NULL, true, CMD_NONE} }; -/* XXX: eventually remove command_chars, but assert they are the same for now */ void show_help(void) -- cgit v1.2.3