mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
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
This commit is contained in:
1 parent
baab2cf821
commit
e7cb1c0776
1 file changed
+22
-5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335037
+22
-5
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user