fix(cli): cli now does not try to execute the command when argc is wrong

This commit is contained in:
lisk77 2025-12-01 20:10:19 +01:00
parent 31388f077d
commit b22c44f1ec

View file

@ -36,7 +36,9 @@ int main(int argc, char** argv) {
for (size_t i = 0; i < iter; i++) { for (size_t i = 0; i < iter; i++) {
if (strcmp(subcmd, commands[i].name) == 0) { if (strcmp(subcmd, commands[i].name) == 0) {
if (argc < commands[i].min_args || argc > commands[i].max_args) { if (argc < commands[i].min_args || argc > commands[i].max_args) {
printf("ERROR: invalid args for %s\n", subcmd); printf("ERROR: invalid amount of args for %s\n", subcmd);
printf("%s\n", commands[i].usage);
return 1;
} }
commands[i].func(argc, argv); commands[i].func(argc, argv);
return 0; return 0;