2008-08-13 13:54:53 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
#include <getopt.h>
|
2011-06-06 15:14:38 +00:00
|
|
|
#include <complete.h>
|
2008-08-13 13:54:53 +00:00
|
|
|
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
|
|
|
|
static void list_group(int verbose, const char *grpname, uint32_t group)
|
|
|
|
{
|
|
|
|
struct command *cmdtp;
|
|
|
|
bool first = true;
|
|
|
|
int pos = 0;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
for_each_command(cmdtp) {
|
|
|
|
if (cmdtp->group != group)
|
|
|
|
continue;
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
printf("%s commands:\n", grpname);
|
|
|
|
if (!verbose) {
|
|
|
|
printf(" ");
|
|
|
|
pos = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (verbose) {
|
|
|
|
printf(" %-21s %s\n", cmdtp->name, cmdtp->usage);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
len = strlen(cmdtp->name);
|
|
|
|
if (pos + len + 2 > 77) {
|
|
|
|
printf("\n %s", cmdtp->name);
|
|
|
|
pos = len + 2;
|
|
|
|
} else {
|
|
|
|
if (pos != 2) {
|
|
|
|
printf(", ");
|
|
|
|
pos += 2;
|
|
|
|
}
|
|
|
|
printf(cmdtp->name);
|
|
|
|
pos += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!first)
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
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, "File", CMD_GRP_FILE);
|
|
|
|
list_group(verbose, "Scripting", CMD_GRP_SCRIPT);
|
|
|
|
list_group(verbose, "Network", CMD_GRP_NET);
|
|
|
|
list_group(verbose, "Console", CMD_GRP_CONSOLE);
|
|
|
|
list_group(verbose, "Memory", CMD_GRP_MEM);
|
|
|
|
list_group(verbose, "Hardware manipulation", CMD_GRP_HWMANIP);
|
|
|
|
list_group(verbose, "Miscellaneous", CMD_GRP_MISC);
|
|
|
|
list_group(verbose, "Ungrouped", 0);
|
|
|
|
printf("Use 'help COMMAND' for more details.\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-13 13:54:53 +00:00
|
|
|
/*
|
|
|
|
* Use puts() instead of printf() to avoid printf buffer overflow
|
|
|
|
* for long help messages
|
|
|
|
*/
|
2011-12-21 13:18:57 +00:00
|
|
|
static int do_help(int argc, char *argv[])
|
2008-08-13 13:54:53 +00:00
|
|
|
{
|
2011-12-21 13:18:57 +00:00
|
|
|
struct command *cmdtp;
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
int opt, verbose = 0;
|
2012-10-11 22:14:29 +00:00
|
|
|
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
while ((opt = getopt(argc, argv, "v")) > 0) {
|
|
|
|
switch (opt) {
|
|
|
|
case 'v':
|
|
|
|
verbose = 1;
|
|
|
|
break;
|
2008-08-13 13:54:53 +00:00
|
|
|
}
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (optind == argc) { /* show list of commands */
|
|
|
|
list_commands(verbose);
|
2008-08-13 13:54:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* command help (long version) */
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
if ((cmdtp = find_cmd(argv[optind])) != NULL) {
|
2009-12-15 08:11:09 +00:00
|
|
|
barebox_cmd_usage(cmdtp);
|
2008-08-13 13:54:53 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
printf ("Unknown command '%s' - try 'help'"
|
|
|
|
" without arguments for list of all"
|
|
|
|
" known commands\n\n", argv[1]
|
|
|
|
);
|
|
|
|
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"
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
"Without arguments, it lists all all commands.\n\n"
|
2008-08-13 13:54:53 +00:00
|
|
|
"To get detailed help information for specific commands you can type\n"
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
"'help' with a command names as argument.\n";
|
2008-08-13 13:54:53 +00:00
|
|
|
|
|
|
|
static const char *help_aliases[] = { "?", NULL};
|
|
|
|
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_START(help)
|
2008-08-13 13:54:53 +00:00
|
|
|
.cmd = do_help,
|
|
|
|
.aliases = help_aliases,
|
|
|
|
.usage = "print online help",
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
BAREBOX_CMD_GROUP(CMD_GRP_INFO)
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_HELP(cmd_help_help)
|
2011-06-06 15:14:38 +00:00
|
|
|
BAREBOX_CMD_COMPLETE(command_complete)
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_END
|
2008-08-13 13:54:53 +00:00
|
|
|
|