Date: Wed, 13 Jun 2018 08:52:07 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335037 - head/usr.bin/top Message-ID: <201806130852.w5D8q7tV093576@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Wed Jun 13 08:52:06 2018 New Revision: 335037 URL: https://svnweb.freebsd.org/changeset/base/335037 Log: top(1): format help more nicely For entries that are duplicates present them nicely rather than showing two identical help entries. For ' ' present it as SPC Modified: head/usr.bin/top/commands.c Modified: head/usr.bin/top/commands.c ============================================================================== --- head/usr.bin/top/commands.c Wed Jun 13 08:52:04 2018 (r335036) +++ head/usr.bin/top/commands.c Wed Jun 13 08:52:06 2018 (r335037) @@ -57,16 +57,16 @@ const struct command all_commands[] = {'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}, + {'?', NULL, true, CMD_help}, {'i', "toggle the displaying of idle processes", false, CMD_idletog}, - {'I', "toggle the displaying of idle processes", false, CMD_idletog}, + {'I', NULL, 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}, + {'#', NULL, 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}, @@ -86,7 +86,9 @@ const struct command all_commands[] = void show_help(void) { - const struct command *curcmd; + const struct command *curcmd, *nextcmd; + char keys[8] = ""; + _Static_assert(sizeof(keys) >= sizeof("a or b"), "keys right size"); printf("Top version FreeBSD, %s\n", copyright); curcmd = all_commands; @@ -95,7 +97,22 @@ show_help(void) ++curcmd; continue; } - printf("%c\t- %s\n", curcmd->c, curcmd->desc); + if (curcmd->desc == NULL) { + /* we already printed this */ + ++curcmd; + continue; + } + nextcmd = curcmd + 1; + if (nextcmd->desc == NULL && nextcmd->c != '\0') { + sprintf(keys, "%c or %c", curcmd->c, nextcmd->c); + } else if (curcmd->c == ' '){ + /* special case space rather than introducing a "display string" to + * the struct */ + sprintf(keys, "SPC"); + } else { + sprintf(keys, "%c", curcmd->c); + } + printf("%s\t- %s\n", keys, curcmd->desc); ++curcmd; } if (overstrike)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806130852.w5D8q7tV093576>