summaryrefslogtreecommitdiffstats
path: root/commands/help.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands/help.c')
-rw-r--r--commands/help.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/commands/help.c b/commands/help.c
index 7f31ce1f5d..9c33807fad 100644
--- a/commands/help.c
+++ b/commands/help.c
@@ -42,7 +42,7 @@ static void list_group(int verbose, const char *grpname, uint32_t group)
}
}
if (verbose) {
- printf(" %-21s %s\n", cmdtp->name, cmdtp->usage);
+ printf(" %-21s %s\n", cmdtp->name, cmdtp->desc);
continue;
}
len = strlen(cmdtp->name);
@@ -67,8 +67,8 @@ static void list_commands(int verbose)
putchar('\n');
list_group(verbose, "Information", CMD_GRP_INFO);
list_group(verbose, "Boot", CMD_GRP_BOOT);
- list_group(verbose, "Environment", CMD_GRP_ENV);
list_group(verbose, "Partition", CMD_GRP_PART);
+ list_group(verbose, "Environment", CMD_GRP_ENV);
list_group(verbose, "File", CMD_GRP_FILE);
list_group(verbose, "Scripting", CMD_GRP_SCRIPT);
list_group(verbose, "Network", CMD_GRP_NET);
@@ -88,21 +88,31 @@ static void list_commands(int verbose)
static int do_help(int argc, char *argv[])
{
struct command *cmdtp;
- int opt, verbose = 0;
+ int opt, verbose = 0, all = 0;
- while ((opt = getopt(argc, argv, "v")) > 0) {
+ while ((opt = getopt(argc, argv, "va")) > 0) {
switch (opt) {
case 'v':
verbose = 1;
break;
+ case 'a':
+ all = 1;
+ break;
}
}
+ if (all) {
+ for_each_command(cmdtp)
+ barebox_cmd_usage(cmdtp);
+ return 0;
+ }
+
if (optind == argc) { /* show list of commands */
list_commands(verbose);
return 0;
}
+
/* command help (long version) */
if ((cmdtp = find_cmd(argv[optind])) != NULL) {
barebox_cmd_usage(cmdtp);
@@ -110,25 +120,30 @@ static int do_help(int argc, char *argv[])
} else {
printf ("Unknown command '%s' - try 'help'"
" without arguments for list of all"
- " known commands\n\n", argv[1]
+ " known commands\n\n", argv[optind]
);
return 1;
}
}
-static const __maybe_unused char cmd_help_help[] =
-"Show help information (for 'command')\n"
-"'help' prints online help for the monitor commands.\n\n"
-"Without arguments, it lists all all commands.\n\n"
-"To get detailed help information for specific commands you can type\n"
-"'help' with a command names as argument.\n";
+
+BAREBOX_CMD_HELP_START(help)
+BAREBOX_CMD_HELP_TEXT("Without arguments, lists all all commands. With an argument, print help")
+BAREBOX_CMD_HELP_TEXT("about the specified command. If the argument is 'all', then output help")
+BAREBOX_CMD_HELP_TEXT("for all commands.")
+BAREBOX_CMD_HELP_TEXT("")
+BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-a", "output help on all commands")
+BAREBOX_CMD_HELP_OPT ("-v", "verbose")
+BAREBOX_CMD_HELP_END
static const char *help_aliases[] = { "?", NULL};
BAREBOX_CMD_START(help)
.cmd = do_help,
.aliases = help_aliases,
- .usage = "print online help",
+ BAREBOX_CMD_DESC("print online help")
+ BAREBOX_CMD_OPTS("[-v] [COMMAND]")
BAREBOX_CMD_GROUP(CMD_GRP_INFO)
BAREBOX_CMD_HELP(cmd_help_help)
BAREBOX_CMD_COMPLETE(command_complete)