Skip to content

Commit 4e8b019

Browse files
fix case for enum value names
1 parent 9108920 commit 4e8b019

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

code/logic/fossil/io/parser.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ extern "C" {
2222

2323
// Types of command argument
2424
typedef enum {
25-
FOSSIL_io_PARSER_BOOL, // Boolean (enable/disable)
26-
FOSSIL_io_PARSER_STRING, // String argument
27-
FOSSIL_io_PARSER_INT, // Integer argument
28-
FOSSIL_io_PARSER_COMBO // Combo of predefined values
25+
FOSSIL_IO_PARSER_BOOL, // Boolean (enable/disable)
26+
FOSSIL_IO_PARSER_STRING, // String argument
27+
FOSSIL_IO_PARSER_INT, // Integer argument
28+
FOSSIL_IO_PARSER_COMBO // Combo of predefined values
2929
} fossil_io_parser_arg_type_t;
3030

3131
// Structure to represent each argument in the command

code/logic/parser.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ void show_help(const char *command_name, const fossil_io_parser_palette_t *palet
9494
while (arg) {
9595
printf(" --%s (%s): %s\n",
9696
arg->name,
97-
arg->type == FOSSIL_io_PARSER_BOOL ? "bool" :
98-
arg->type == FOSSIL_io_PARSER_STRING ? "string" :
99-
arg->type == FOSSIL_io_PARSER_INT ? "int" :
97+
arg->type == FOSSIL_IO_PARSER_BOOL ? "bool" :
98+
arg->type == FOSSIL_IO_PARSER_STRING ? "string" :
99+
arg->type == FOSSIL_IO_PARSER_INT ? "int" :
100100
"combo",
101101
arg->value ? arg->value : "No default value");
102-
if (arg->type == FOSSIL_io_PARSER_COMBO) {
102+
if (arg->type == FOSSIL_IO_PARSER_COMBO) {
103103
printf(" Options: ");
104104
for (int i = 0; i < arg->combo_count; i++) {
105105
printf("%s%s", arg->combo_options[i], i == arg->combo_count - 1 ? "" : ", ");
@@ -130,13 +130,13 @@ void show_usage(const char *command_name, const fossil_io_parser_palette_t *pale
130130
fossil_io_parser_argument_t *arg = command->arguments;
131131
while (arg) {
132132
printf(" --%s ", arg->name);
133-
if (arg->type == FOSSIL_io_PARSER_STRING) {
133+
if (arg->type == FOSSIL_IO_PARSER_STRING) {
134134
printf("<string>");
135-
} else if (arg->type == FOSSIL_io_PARSER_INT) {
135+
} else if (arg->type == FOSSIL_IO_PARSER_INT) {
136136
printf("<int>");
137-
} else if (arg->type == FOSSIL_io_PARSER_BOOL) {
137+
} else if (arg->type == FOSSIL_IO_PARSER_BOOL) {
138138
printf("<true/false>");
139-
} else if (arg->type == FOSSIL_io_PARSER_COMBO) {
139+
} else if (arg->type == FOSSIL_IO_PARSER_COMBO) {
140140
printf("<%s>", arg->combo_options[0]); // Show first combo option
141141
}
142142
arg = arg->next;
@@ -239,7 +239,7 @@ void fossil_io_parser_parse(fossil_io_parser_palette_t *palette, int argc, char
239239
while (argument) {
240240
if (strcmp(argument->name, arg_value) == 0) {
241241
switch (argument->type) {
242-
case FOSSIL_io_PARSER_BOOL:
242+
case FOSSIL_IO_PARSER_BOOL:
243243
argument->value = malloc(sizeof(int));
244244
if (strcmp(arg_value, "enable") == 0) {
245245
*(int *)argument->value = 1; // Enable
@@ -251,14 +251,14 @@ void fossil_io_parser_parse(fossil_io_parser_palette_t *palette, int argc, char
251251
argument->value = NULL;
252252
}
253253
break;
254-
case FOSSIL_io_PARSER_STRING:
254+
case FOSSIL_IO_PARSER_STRING:
255255
argument->value = _custom_strdup(arg_value); // Custom _custom_strdup
256256
break;
257-
case FOSSIL_io_PARSER_INT:
257+
case FOSSIL_IO_PARSER_INT:
258258
argument->value = malloc(sizeof(int));
259259
*(int *)argument->value = atoi(arg_value);
260260
break;
261-
case FOSSIL_io_PARSER_COMBO:
261+
case FOSSIL_IO_PARSER_COMBO:
262262
for (int j = 0; j < argument->combo_count; j++) {
263263
if (strcmp(arg_value, argument->combo_options[j]) == 0) {
264264
argument->value = _custom_strdup(arg_value);
@@ -279,7 +279,7 @@ void fossil_io_parser_free(fossil_io_parser_palette_t *palette) {
279279
while (command) {
280280
fossil_io_parser_argument_t *argument = command->arguments;
281281
while (argument) {
282-
if (argument->type == FOSSIL_io_PARSER_COMBO) {
282+
if (argument->type == FOSSIL_IO_PARSER_COMBO) {
283283
free(argument->combo_options);
284284
}
285285
free(argument->name);

code/tests/cases/test_parser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ FOSSIL_TEST_CASE(c_add_command) {
6767
FOSSIL_TEST_CASE(c_add_argument) {
6868
fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description");
6969
fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description");
70-
fossil_io_parser_argument_t *argument = fossil_io_parser_add_argument(command, "test_arg", FOSSIL_io_PARSER_STRING, NULL, 0);
70+
fossil_io_parser_argument_t *argument = fossil_io_parser_add_argument(command, "test_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
7171
FOSSIL_TEST_ASSUME(argument != NULL, "Argument should be added");
7272
FOSSIL_TEST_ASSUME(strcmp(argument->name, "test_arg") == 0, "Argument name should be 'test_arg'");
73-
FOSSIL_TEST_ASSUME(argument->type == FOSSIL_io_PARSER_STRING, "Argument type should be STRING");
73+
FOSSIL_TEST_ASSUME(argument->type == FOSSIL_IO_PARSER_STRING, "Argument type should be STRING");
7474
FOSSIL_TEST_ASSUME(argument->value == NULL, "Argument value should be NULL");
7575
FOSSIL_TEST_ASSUME(command->arguments == argument, "Command arguments should include the new argument");
7676
fossil_io_parser_free(palette);
@@ -79,7 +79,7 @@ FOSSIL_TEST_CASE(c_add_argument) {
7979
FOSSIL_TEST_CASE(c_parse_command) {
8080
fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description");
8181
fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description");
82-
fossil_io_parser_add_argument(command, "test_arg", FOSSIL_io_PARSER_STRING, NULL, 0);
82+
fossil_io_parser_add_argument(command, "test_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
8383

8484
char *argv[] = {"program", "test_command", "test_arg", "test_value"};
8585
fossil_io_parser_parse(palette, 4, argv);

code/tests/cases/test_parser.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ FOSSIL_TEST_CASE(cpp_add_command) {
6969
FOSSIL_TEST_CASE(cpp_add_argument) {
7070
fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description");
7171
fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description");
72-
fossil_io_parser_argument_t *argument = fossil_io_parser_add_argument(command, "test_arg", FOSSIL_io_PARSER_STRING, NULL, 0);
72+
fossil_io_parser_argument_t *argument = fossil_io_parser_add_argument(command, "test_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
7373
FOSSIL_TEST_ASSUME(argument != NULL, "Argument should be added");
7474
FOSSIL_TEST_ASSUME(strcmp(argument->name, "test_arg") == 0, "Argument name should be 'test_arg'");
75-
FOSSIL_TEST_ASSUME(argument->type == FOSSIL_io_PARSER_STRING, "Argument type should be STRING");
75+
FOSSIL_TEST_ASSUME(argument->type == FOSSIL_IO_PARSER_STRING, "Argument type should be STRING");
7676
FOSSIL_TEST_ASSUME(argument->value == NULL, "Argument value should be NULL");
7777
FOSSIL_TEST_ASSUME(command->arguments == argument, "Command arguments should include the new argument");
7878
fossil_io_parser_free(palette);
@@ -81,7 +81,7 @@ FOSSIL_TEST_CASE(cpp_add_argument) {
8181
FOSSIL_TEST_CASE(cpp_parse_command) {
8282
fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description");
8383
fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description");
84-
fossil_io_parser_add_argument(command, "test_arg", FOSSIL_io_PARSER_STRING, NULL, 0);
84+
fossil_io_parser_add_argument(command, "test_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
8585

8686
std::vector<std::string> argv = {"program", "test_command", "test_arg", "test_value"};
8787
std::vector<const char*> argv_cstr;
@@ -129,10 +129,10 @@ FOSSIL_TEST_CASE(cpp_wrapper_add_argument) {
129129
fossil::io::Parser parser;
130130
fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description");
131131
fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description");
132-
fossil_io_parser_argument_t *argument = parser.add_argument(command, "wrapper_arg", FOSSIL_io_PARSER_STRING, NULL, 0);
132+
fossil_io_parser_argument_t *argument = parser.add_argument(command, "wrapper_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
133133
FOSSIL_TEST_ASSUME(argument != NULL, "Argument should be added");
134134
FOSSIL_TEST_ASSUME(strcmp(argument->name, "wrapper_arg") == 0, "Argument name should be 'wrapper_arg'");
135-
FOSSIL_TEST_ASSUME(argument->type == FOSSIL_io_PARSER_STRING, "Argument type should be STRING");
135+
FOSSIL_TEST_ASSUME(argument->type == FOSSIL_IO_PARSER_STRING, "Argument type should be STRING");
136136
FOSSIL_TEST_ASSUME(argument->value == NULL, "Argument value should be NULL");
137137
FOSSIL_TEST_ASSUME(command->arguments == argument, "Command arguments should include the new argument");
138138
parser.free(palette);
@@ -142,7 +142,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_parse_command) {
142142
fossil::io::Parser parser;
143143
fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description");
144144
fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description");
145-
parser.add_argument(command, "wrapper_arg", FOSSIL_io_PARSER_STRING, NULL, 0);
145+
parser.add_argument(command, "wrapper_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
146146

147147
std::vector<std::string> argv = {"program", "wrapper_command", "wrapper_arg", "wrapper_value"};
148148
std::vector<const char*> argv_cstr;

0 commit comments

Comments
 (0)