Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
int command_dispatch(struct pakfire* pakfire, const struct command* commands, int argc, char* argv[]) {
const struct command* command = NULL;
- if (!argc) {
+ if (argc < 2) {
fprintf(stderr, "Command required\n");
return -EINVAL;
}
- const char* verb = argv[0];
+ const char* verb = argv[1];
// Find a matching command
command = command_find(commands, verb);
return -EINVAL;
}
+ // Consume the verb
+ argv++;
+ argc--;
+
// Reset optind
optind = 1;
goto ERROR;
// Run a command
- r = cli_main(pakfire, argc - optind, argv + optind);
+ r = cli_main(pakfire, argc - optind + 1, argv + optind - 1);
ERROR:
if (pakfire)
cli_set_repo_enabled(pakfire, config.disable_repos[i], 0);
// Run a command
- r = cli_main(pakfire, argc - optind, argv + optind);
+ r = cli_main(pakfire, argc - optind + 1, argv + optind - 1);
ERROR:
if (f)