Skip to content

Commit 17af088

Browse files
Merge pull request #101 from dreamer-coding/add_options_flag
2 parents eb227ab + c77acba commit 17af088

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ The Pizza Test CLI provides an efficient way to run and manage tests directly fr
8787
| `--only <test>` | Run only the specified test. | Focuses execution on a single test for debugging or validation purposes. |
8888
| `--repeat <count>` | Repeat the test a specified number of times. | Useful for stress testing or verifying consistency across multiple runs. |
8989
| `--help` | Show help for the run command. | Provides detailed usage instructions for the `run` command. |
90-
9190
### Filter Command Options
9291
| Option | Description | Notes |
9392
|----------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
93+
| `--options` | Show all available filter options. | Provides a comprehensive list of filter-related flags and their usage. |
9494
| `--test-name <name>` | Filter by test name. | Enables precise targeting of individual tests. |
9595
| `--suite-name <name>`| Filter by suite name. | Useful for running all tests within a specific suite. |
9696
| `--tag <tag>` | Filter by tag. | Allows grouping and execution of tests based on custom tags. |
@@ -99,13 +99,15 @@ The Pizza Test CLI provides an efficient way to run and manage tests directly fr
9999
### Sort Command Options
100100
| Option | Description | Notes |
101101
|----------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
102+
| `--options` | Show all available sort options. | Provides a comprehensive list of sort-related flags and their usage. |
102103
| `--by <criteria>` | Sort by specified criteria. | Common criteria include execution time, name, or priority. |
103104
| `--order <asc/desc>` | Sort in ascending or descending order. | Helps organize test execution based on preferred order. |
104105
| `--help` | Show help for the sort command. | Provides detailed usage instructions for the `sort` command. |
105106

106107
### Shuffle Command Options
107108
| Option | Description |
108109
|----------------------|-----------------------------------------------------------------------------------------------|
110+
| `--options` | Show all available shuffle options. |
109111
| `--seed <seed>` | Specify the seed for shuffling. |
110112
| `--count <count>` | Number of items to shuffle. |
111113
| `--by <criteria>` | Shuffle by specified criteria. |

code/logic/common.c

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static void _show_subhelp_filter(void) {
110110
pizza_io_printf("{cyan} --suite-name <name> Filter by suite name{reset}\n");
111111
pizza_io_printf("{cyan} --tag <tag> Filter by tag{reset}\n");
112112
pizza_io_printf("{cyan} --help Show help for filter command{reset}\n");
113+
pizza_io_printf("{cyan} --options Show all valid tags{reset}\n");
113114
exit(EXIT_SUCCESS);
114115
}
115116

@@ -118,6 +119,7 @@ static void _show_subhelp_sort(void) {
118119
pizza_io_printf("{cyan} --by <criteria> Sort by specified criteria{reset}\n");
119120
pizza_io_printf("{cyan} --order <asc|desc> Sort in ascending or descending order{reset}\n");
120121
pizza_io_printf("{cyan} --help Show help for sort command{reset}\n");
122+
pizza_io_printf("{cyan} --options Show all valid criteria{reset}\n");
121123
exit(EXIT_SUCCESS);
122124
}
123125

@@ -127,6 +129,7 @@ static void _show_subhelp_shuffle(void) {
127129
pizza_io_printf("{cyan} --count <count> Number of items to shuffle{reset}\n");
128130
pizza_io_printf("{cyan} --by <criteria> Shuffle by specified criteria{reset}\n");
129131
pizza_io_printf("{cyan} --help Show help for shuffle command{reset}\n");
132+
pizza_io_printf("{cyan} --options Show all valid criteria for shuffling{reset}\n");
130133
exit(EXIT_SUCCESS);
131134
}
132135

@@ -256,6 +259,12 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
256259
}
257260
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
258261
_show_subhelp_filter();
262+
} else if (pizza_io_cstr_compare(argv[j], "--options") == 0) {
263+
pizza_io_printf("{blue}Valid tags:{reset}\n");
264+
for (int k = 0; VALID_TAGS[k] != null; k++) {
265+
pizza_io_printf("{cyan} %s{reset}\n", VALID_TAGS[k]);
266+
}
267+
exit(EXIT_SUCCESS);
259268
} else {
260269
break;
261270
}
@@ -284,6 +293,12 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
284293
pallet.sort.order = argv[++j];
285294
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
286295
_show_subhelp_sort();
296+
} else if (pizza_io_cstr_compare(argv[j], "--options") == 0) {
297+
pizza_io_printf("{blue}Valid criteria:{reset}\n");
298+
for (int k = 0; VALID_CRITERIA[k] != null; k++) {
299+
pizza_io_printf("{cyan} %s{reset}\n", VALID_CRITERIA[k]);
300+
}
301+
exit(EXIT_SUCCESS);
287302
} else {
288303
break;
289304
}
@@ -294,17 +309,23 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
294309
pallet.shuffle.by = null;
295310

296311
for (int j = i + 1; j < argc; j++) {
297-
if (pizza_io_cstr_compare(argv[j], "--seed") == 0 && j + 1 < argc) {
298-
pallet.shuffle.seed = argv[++j];
299-
} else if (pizza_io_cstr_compare(argv[j], "--count") == 0 && j + 1 < argc) {
300-
pallet.shuffle.count = atoi(argv[++j]);
301-
} else if (pizza_io_cstr_compare(argv[j], "--by") == 0 && j + 1 < argc) {
302-
pallet.shuffle.by = argv[++j];
303-
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
304-
_show_subhelp_shuffle();
305-
} else {
306-
break;
312+
if (pizza_io_cstr_compare(argv[j], "--seed") == 0 && j + 1 < argc) {
313+
pallet.shuffle.seed = argv[++j];
314+
} else if (pizza_io_cstr_compare(argv[j], "--count") == 0 && j + 1 < argc) {
315+
pallet.shuffle.count = atoi(argv[++j]);
316+
} else if (pizza_io_cstr_compare(argv[j], "--by") == 0 && j + 1 < argc) {
317+
pallet.shuffle.by = argv[++j];
318+
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
319+
_show_subhelp_shuffle();
320+
} else if (pizza_io_cstr_compare(argv[j], "--options") == 0) {
321+
pizza_io_printf("{blue}Valid criteria for shuffling:{reset}\n");
322+
for (int k = 0; VALID_CRITERIA[k] != null; k++) {
323+
pizza_io_printf("{cyan} %s{reset}\n", VALID_CRITERIA[k]);
307324
}
325+
exit(EXIT_SUCCESS);
326+
} else {
327+
break;
328+
}
308329
}
309330
} else if (strncmp(argv[i], "color=", 6) == 0) {
310331
if (pizza_io_cstr_compare(argv[i] + 6, "enable") == 0) {

0 commit comments

Comments
 (0)