]> git.ipfire.org Git - pakfire.git/commitdiff
cli: Declare command outside the switch statement
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Oct 2024 13:54:24 +0000 (13:54 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Oct 2024 15:14:04 +0000 (15:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/command.c

index 28a13fb6ff30f6a567bdc14ffd210e6b0a01ee26..5a9bcb20fb8d0006b73880d1a26ad265ff159f36 100644 (file)
@@ -96,6 +96,8 @@ struct command_ctx {
 static error_t __command_parse(int key, char* arg, struct argp_state* state) {
        struct command_ctx* ctx = state->input;
 
+       const struct command* command = NULL;
+
        // Just call the parse function if we don't have any commands
        if (!ctx->commands) {
                if (!ctx->parse)
@@ -112,7 +114,7 @@ static error_t __command_parse(int key, char* arg, struct argp_state* state) {
 
                // Try to find a command
                case ARGP_KEY_ARG:
-                       const struct command* command = ctx->command = command_find(ctx->commands, arg);
+                       command = ctx->command = command_find(ctx->commands, arg);
 
                        // Fail if the command wasn't found
                        if (!command) {