diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-24 22:18:28 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-25 10:29:05 -0800 |
commit | 910bb250c479b4de9c30231e1a090e9a2d647434 (patch) | |
tree | 7e85f8ca64412e099aba74aba1c62e64c49d9893 /src/helper | |
parent | c297a14f7072d98bdad6bd7b9bac3a3069de9ed9 (diff) | |
download | openocd_libswd-910bb250c479b4de9c30231e1a090e9a2d647434.tar.gz openocd_libswd-910bb250c479b4de9c30231e1a090e9a2d647434.tar.bz2 openocd_libswd-910bb250c479b4de9c30231e1a090e9a2d647434.tar.xz openocd_libswd-910bb250c479b4de9c30231e1a090e9a2d647434.zip |
combine help and usage command handlers
Remove duplicated handler code by checking the running command name.
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/command.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/helper/command.c b/src/helper/command.c index a1ba3585..54eec3b6 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -861,30 +861,18 @@ static COMMAND_HELPER(command_help_show, struct command *c, unsigned n, } COMMAND_HANDLER(handle_help_command) { - struct command *c = CMD_CTX->commands; - - if (0 == CMD_ARGC) - return CALL_COMMAND_HANDLER(command_help_show_list, c, 0, true); + bool full = strcmp(CMD_NAME, "help") == 0; - int retval = CALL_COMMAND_HANDLER(command_help_find, c, &c); - if (ERROR_OK != retval) - return retval; - - return CALL_COMMAND_HANDLER(command_help_show, c, 0, true); -} - -COMMAND_HANDLER(handle_usage_command) -{ struct command *c = CMD_CTX->commands; if (0 == CMD_ARGC) - return CALL_COMMAND_HANDLER(command_help_show_list, c, 0, false); + return CALL_COMMAND_HANDLER(command_help_show_list, c, 0, full); int retval = CALL_COMMAND_HANDLER(command_help_find, c, &c); if (ERROR_OK != retval) return retval; - return CALL_COMMAND_HANDLER(command_help_show, c, 0, false); + return CALL_COMMAND_HANDLER(command_help_show, c, 0, full); } static int command_unknown_find(unsigned argc, Jim_Obj *const *argv, @@ -1106,15 +1094,15 @@ static const struct command_registration command_builtin_handlers[] = { .name = "help", .handler = &handle_help_command, .mode = COMMAND_ANY, - .help = "show built-in command help", - .usage = "[<command_name> ...]", + .help = "show full command help", + .usage = "[<command> ...]", }, { .name = "usage", - .handler = &handle_usage_command, + .handler = &handle_help_command, .mode = COMMAND_ANY, - .help = "show command usage", - .usage = "[<command_name> ...]", + .help = "show basic command usage", + .usage = "[<command> ...]", }, COMMAND_REGISTRATION_DONE }; |