diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-05-25 13:17:21 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-05-25 13:34:06 -0700 |
commit | e704c712ad473160e97717f139ab3929bcd249c1 (patch) | |
tree | 1b87c7ad05a1e97bd04326adc7f6b6239407b10e /include/console.h | |
parent | 89e1d5a1219c87d90e1362716f799b16aad5c921 (diff) | |
download | chrome-ec-e704c712ad473160e97717f139ab3929bcd249c1.tar.gz |
Better help for console commands
Additional help messages and usage are gated by
CONFIG_CONSOLE_CMDHELP, so we can turn it on if there's space (adds
about 3KB to image size) and turn it off when there isn't.
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=none
TEST=manual
1) help
2) help list
3) help gpioset
4) gpioset -> wrong number of params
5) gpioset fred 0 -> param1 bad
6) gpioset cpu_prochot fred -> param2 bad
Change-Id: Ibe99f37212020f763ebe65a068e6aa83a809a370
Diffstat (limited to 'include/console.h')
-rw-r--r-- | include/console.h | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/include/console.h b/include/console.h index 4a655387da..3ad4150fe4 100644 --- a/include/console.h +++ b/include/console.h @@ -8,6 +8,7 @@ #ifndef __CROS_EC_CONSOLE_H #define __CROS_EC_CONSOLE_H +#include "board.h" #include "common.h" /* Console command; used by DECLARE_CONSOLE_COMMAND macro. */ @@ -16,6 +17,12 @@ struct console_command { const char *name; /* Handler for the command. argv[0] will be the command name. */ int (*handler)(int argc, char **argv); +#ifdef CONFIG_CONSOLE_CMDHELP + /* Description of args */ + const char *argdesc; + /* Short help for command */ + const char *shorthelp; +#endif }; @@ -80,10 +87,18 @@ void console_has_input(void); * Register a console command handler. Note that `name' must never be a * beginning of another existing command name. */ -#define DECLARE_CONSOLE_COMMAND(name, routine) \ - static const char __con_cmd_label_##name[] = #name; \ - const struct console_command __con_cmd_##name \ - __attribute__((section(".rodata.cmds." #name))) \ - = {__con_cmd_label_##name, routine} +#ifdef CONFIG_CONSOLE_CMDHELP +#define DECLARE_CONSOLE_COMMAND(name, routine, argdesc, shorthelp, longhelp) \ + static const char __con_cmd_label_##name[] = #name; \ + const struct console_command __con_cmd_##name \ + __attribute__((section(".rodata.cmds." #name))) \ + = {__con_cmd_label_##name, routine, argdesc, shorthelp} +#else +#define DECLARE_CONSOLE_COMMAND(name, routine, argdesc, shorthelp, longhelp) \ + static const char __con_cmd_label_##name[] = #name; \ + const struct console_command __con_cmd_##name \ + __attribute__((section(".rodata.cmds." #name))) \ + = {__con_cmd_label_##name, routine} +#endif #endif /* __CROS_EC_CONSOLE_H */ |