commands: gaps: Refactor, expected_syntax.
This commit is contained in:
parent
58085226b3
commit
820681965d
|
@ -760,6 +760,8 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1))) {
|
if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
const char* expected_syntax =
|
||||||
|
"Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'";
|
||||||
const char *amount_str = argv[0];
|
const char *amount_str = argv[0];
|
||||||
// gaps amount
|
// gaps amount
|
||||||
if (argc >= 1 && isdigit(*amount_str)) {
|
if (argc >= 1 && isdigit(*amount_str)) {
|
||||||
|
@ -793,7 +795,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
// gaps inner|outer current|all set|plus|minus n
|
// gaps inner|outer current|all set|plus|minus n
|
||||||
if (argc < 4 || config->reading) {
|
if (argc < 4 || config->reading) {
|
||||||
return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'");
|
return cmd_results_new(CMD_INVALID, "gaps", expected_syntax);
|
||||||
}
|
}
|
||||||
// gaps inner|outer ...
|
// gaps inner|outer ...
|
||||||
const char *inout_str = argv[0];
|
const char *inout_str = argv[0];
|
||||||
|
@ -803,7 +805,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
|
||||||
} else if (strcasecmp(inout_str, "outer") == 0) {
|
} else if (strcasecmp(inout_str, "outer") == 0) {
|
||||||
inout = OUTER;
|
inout = OUTER;
|
||||||
} else {
|
} else {
|
||||||
return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'");
|
return cmd_results_new(CMD_INVALID, "gaps", expected_syntax);
|
||||||
}
|
}
|
||||||
|
|
||||||
// gaps ... current|all ...
|
// gaps ... current|all ...
|
||||||
|
@ -821,7 +823,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
|
||||||
target = WORKSPACE;
|
target = WORKSPACE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'");
|
return cmd_results_new(CMD_INVALID, "gaps", expected_syntax);
|
||||||
}
|
}
|
||||||
|
|
||||||
// gaps ... n
|
// gaps ... n
|
||||||
|
@ -843,7 +845,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
|
||||||
method = ADD;
|
method = ADD;
|
||||||
amount *= -1;
|
amount *= -1;
|
||||||
} else {
|
} else {
|
||||||
return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps <inner|outer> <current|all> <set|plus|minus n>'");
|
return cmd_results_new(CMD_INVALID, "gaps", expected_syntax);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == CURRENT) {
|
if (target == CURRENT) {
|
||||||
|
|
Loading…
Reference in a new issue