combine help and usage command handlers
authorZachary T Welch <zw@superlucidity.net>
Wed, 25 Nov 2009 06:18:28 +0000 (22:18 -0800)
committerZachary T Welch <zw@superlucidity.net>
Wed, 25 Nov 2009 18:29:05 +0000 (10:29 -0800)
Remove duplicated handler code by checking the running command name.

src/helper/command.c

index a1ba358500324c17ef204558b86685422d66acc0..54eec3b6f0765fee3d39e38598252c8a68c2ef3d 100644 (file)
@@ -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
 };

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)