Add basic support for mini2440 board to barebox.
[barebox-mini2440.git] / commands / help.c
blobf8387bd6147223aefb9bcfacaf81863a6adb2770
1 /*
2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
6 * project.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
24 #include <common.h>
25 #include <command.h>
28 * Use puts() instead of printf() to avoid printf buffer overflow
29 * for long help messages
31 static int do_help(struct command * cmdtp, int argc, char *argv[])
33 if (argc == 1) { /* show list of commands */
34 for_each_command(cmdtp) {
35 if (!cmdtp->usage)
36 continue;
37 printf("%10s - %s\n", cmdtp->name, cmdtp->usage);
39 return 0;
42 /* command help (long version) */
43 if ((cmdtp = find_cmd(argv[1])) != NULL) {
44 barebox_cmd_usage(cmdtp);
45 return 0;
46 } else {
47 printf ("Unknown command '%s' - try 'help'"
48 " without arguments for list of all"
49 " known commands\n\n", argv[1]
51 return 1;
55 static const __maybe_unused char cmd_help_help[] =
56 "Show help information (for 'command')\n"
57 "'help' prints online help for the monitor commands.\n\n"
58 "Without arguments, it prints a short usage message for all commands.\n\n"
59 "To get detailed help information for specific commands you can type\n"
60 "'help' with one or more command names as arguments.\n";
62 static const char *help_aliases[] = { "?", NULL};
64 BAREBOX_CMD_START(help)
65 .cmd = do_help,
66 .aliases = help_aliases,
67 .usage = "print online help",
68 BAREBOX_CMD_HELP(cmd_help_help)
69 BAREBOX_CMD_END