Skip to content

Commit a71ff5e

Browse files
author
Rob Sanders
committed
Rename cli_int_add_optarg_value to cli_set_optarg_value and make public
1 parent dd44a26 commit a71ff5e

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

clitest.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,11 @@ int shape_transient_eval(struct cli_def *cli, const char *name, const char *valu
254254
printf("shape_transient_eval called with <%s>\n", value);
255255
if (!strcmp(value, "rectangle")) {
256256
cli_set_transient_mode(cli, MODE_POLYGON_RECTANGLE);
257+
cli_set_optarg_value(cli, "duplicateShapeValue", value, 0);
257258
return CLI_OK;
258259
} else if (!strcmp(value, "triangle")) {
259260
cli_set_transient_mode(cli, MODE_POLYGON_TRIANGLE);
261+
cli_set_optarg_value(cli, "duplicateShapeValue", value, 0);
260262
return CLI_OK;
261263
}
262264
cli_error(cli, "unrecognized value for setting %s -> %s", name, value);

libcli.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ static void cli_int_parse_optargs(struct cli_def *cli, struct cli_pipeline_stage
141141
static int cli_int_enter_buildmode(struct cli_def *cli, struct cli_pipeline_stage *stage, char *mode_text);
142142
static char *cli_int_buildmode_extend_cmdline(char *, char *word);
143143
static void cli_int_free_buildmode(struct cli_def *cli);
144-
static int cli_int_add_optarg_value(struct cli_def *cli, const char *name, const char *value, int allow_multiple);
145144
static void cli_free_command(struct cli_def *cli, struct cli_command *cmd);
146145
static int cli_int_unregister_command_core(struct cli_def *cli, const char *command, int command_type);
147146
static int cli_int_unregister_buildmode_command(struct cli_def *cli, const char *command) __attribute__((unused));
@@ -2183,7 +2182,7 @@ void cli_int_unset_optarg_value(struct cli_def *cli, const char *name) {
21832182
}
21842183
}
21852184

2186-
int cli_int_add_optarg_value(struct cli_def *cli, const char *name, const char *value, int allow_multiple) {
2185+
int cli_set_optarg_value(struct cli_def *cli, const char *name, const char *value, int allow_multiple) {
21872186
struct cli_optarg_pair *optarg_pair, **anchor;
21882187
int rc = CLI_ERROR;
21892188

@@ -2452,7 +2451,7 @@ int cli_int_buildmode_flag_cback(struct cli_def *cli, const char *command, char
24522451
cli_error(cli, "Extra arguments on command line, command ignored.");
24532452
rc = CLI_ERROR;
24542453
}
2455-
if (cli_int_add_optarg_value(cli, command, command, 0)) {
2454+
if (cli_set_optarg_value(cli, command, command, 0)) {
24562455
cli_error(cli, "Problem setting value for optional flag %s", command);
24572456
rc = CLI_ERROR;
24582457
}
@@ -2467,7 +2466,7 @@ int cli_int_buildmode_flag_multiple_cback(struct cli_def *cli, const char *comma
24672466
cli_error(cli, "Extra arguments on command line, command ignored.");
24682467
rc = CLI_ERROR;
24692468
}
2470-
if (cli_int_add_optarg_value(cli, command, command, CLI_CMD_OPTION_MULTIPLE)) {
2469+
if (cli_set_optarg_value(cli, command, command, CLI_CMD_OPTION_MULTIPLE)) {
24712470
cli_error(cli, "Problem setting value for optional flag %s", command);
24722471
rc = CLI_ERROR;
24732472
}
@@ -3066,10 +3065,10 @@ static void cli_int_parse_optargs(struct cli_def *cli, struct cli_pipeline_stage
30663065
if (oaptr->flags & CLI_CMD_REMAINDER_OF_LINE) {
30673066
char *combined = NULL;
30683067
combined = join_words(stage->num_words - word_idx, stage->words + word_idx);
3069-
set_value_return = cli_int_add_optarg_value(cli, oaptr->name, combined, 0);
3068+
set_value_return = cli_set_optarg_value(cli, oaptr->name, combined, 0);
30703069
free_z(combined);
30713070
} else {
3072-
set_value_return = cli_int_add_optarg_value(cli, oaptr->name, value, oaptr->flags & CLI_CMD_OPTION_MULTIPLE);
3071+
set_value_return = cli_set_optarg_value(cli, oaptr->name, value, oaptr->flags & CLI_CMD_OPTION_MULTIPLE);
30733072
}
30743073

30753074
if (set_value_return != CLI_OK) {

libcli.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ char *cli_find_optarg_value(struct cli_def *cli, char *name, char *find_after);
241241
struct cli_optarg_pair *cli_get_all_found_optargs(struct cli_def *cli);
242242
int cli_unregister_optarg(struct cli_command *cmd, const char *name);
243243
char *cli_get_optarg_value(struct cli_def *cli, const char *name, char *find_after);
244+
int cli_set_optarg_value(struct cli_def *cli, const char *name, const char *value, int allow_multiple);
244245
void cli_unregister_all_optarg(struct cli_command *c);
245246
void cli_unregister_all_filters(struct cli_def *cli);
246247
void cli_unregister_all_commands(struct cli_def *cli);

0 commit comments

Comments
 (0)