Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ The Pizza Test CLI provides an efficient way to run and manage tests directly fr
| `--only <test>` | Run only the specified test. | Focuses execution on a single test for debugging or validation purposes. |
| `--repeat <count>` | Repeat the test a specified number of times. | Useful for stress testing or verifying consistency across multiple runs. |
| `--help` | Show help for the run command. | Provides detailed usage instructions for the `run` command. |

### Filter Command Options
| Option | Description | Notes |
|----------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
| `--options` | Show all available filter options. | Provides a comprehensive list of filter-related flags and their usage. |
| `--test-name <name>` | Filter by test name. | Enables precise targeting of individual tests. |
| `--suite-name <name>`| Filter by suite name. | Useful for running all tests within a specific suite. |
| `--tag <tag>` | Filter by tag. | Allows grouping and execution of tests based on custom tags. |
Expand All @@ -98,13 +98,15 @@ The Pizza Test CLI provides an efficient way to run and manage tests directly fr
### Sort Command Options
| Option | Description | Notes |
|----------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
| `--options` | Show all available sort options. | Provides a comprehensive list of sort-related flags and their usage. |
| `--by <criteria>` | Sort by specified criteria. | Common criteria include execution time, name, or priority. |
| `--order <asc/desc>` | Sort in ascending or descending order. | Helps organize test execution based on preferred order. |
| `--help` | Show help for the sort command. | Provides detailed usage instructions for the `sort` command. |

### Shuffle Command Options
| Option | Description |
|----------------------|-----------------------------------------------------------------------------------------------|
| `--options` | Show all available shuffle options. |
| `--seed <seed>` | Specify the seed for shuffling. |
| `--count <count>` | Number of items to shuffle. |
| `--by <criteria>` | Shuffle by specified criteria. |
Expand Down
41 changes: 31 additions & 10 deletions code/logic/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ static void _show_subhelp_filter(void) {
pizza_io_printf("{cyan} --suite-name <name> Filter by suite name{reset}\n");
pizza_io_printf("{cyan} --tag <tag> Filter by tag{reset}\n");
pizza_io_printf("{cyan} --help Show help for filter command{reset}\n");
pizza_io_printf("{cyan} --options Show all valid tags{reset}\n");
exit(EXIT_SUCCESS);
}

Expand All @@ -116,6 +117,7 @@ static void _show_subhelp_sort(void) {
pizza_io_printf("{cyan} --by <criteria> Sort by specified criteria{reset}\n");
pizza_io_printf("{cyan} --order <asc|desc> Sort in ascending or descending order{reset}\n");
pizza_io_printf("{cyan} --help Show help for sort command{reset}\n");
pizza_io_printf("{cyan} --options Show all valid criteria{reset}\n");
exit(EXIT_SUCCESS);
}

Expand All @@ -125,6 +127,7 @@ static void _show_subhelp_shuffle(void) {
pizza_io_printf("{cyan} --count <count> Number of items to shuffle{reset}\n");
pizza_io_printf("{cyan} --by <criteria> Shuffle by specified criteria{reset}\n");
pizza_io_printf("{cyan} --help Show help for shuffle command{reset}\n");
pizza_io_printf("{cyan} --options Show all valid criteria for shuffling{reset}\n");
exit(EXIT_SUCCESS);
}

Expand Down Expand Up @@ -254,6 +257,12 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
}
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
_show_subhelp_filter();
} else if (pizza_io_cstr_compare(argv[j], "--options") == 0) {
pizza_io_printf("{blue}Valid tags:{reset}\n");
for (int k = 0; VALID_TAGS[k] != null; k++) {
pizza_io_printf("{cyan} %s{reset}\n", VALID_TAGS[k]);
}
exit(EXIT_SUCCESS);
} else {
break;
}
Expand Down Expand Up @@ -282,6 +291,12 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
pallet.sort.order = argv[++j];
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
_show_subhelp_sort();
} else if (pizza_io_cstr_compare(argv[j], "--options") == 0) {
pizza_io_printf("{blue}Valid criteria:{reset}\n");
for (int k = 0; VALID_CRITERIA[k] != null; k++) {
pizza_io_printf("{cyan} %s{reset}\n", VALID_CRITERIA[k]);
}
exit(EXIT_SUCCESS);
} else {
break;
}
Expand All @@ -292,17 +307,23 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
pallet.shuffle.by = null;

for (int j = i + 1; j < argc; j++) {
if (pizza_io_cstr_compare(argv[j], "--seed") == 0 && j + 1 < argc) {
pallet.shuffle.seed = argv[++j];
} else if (pizza_io_cstr_compare(argv[j], "--count") == 0 && j + 1 < argc) {
pallet.shuffle.count = atoi(argv[++j]);
} else if (pizza_io_cstr_compare(argv[j], "--by") == 0 && j + 1 < argc) {
pallet.shuffle.by = argv[++j];
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
_show_subhelp_shuffle();
} else {
break;
if (pizza_io_cstr_compare(argv[j], "--seed") == 0 && j + 1 < argc) {
pallet.shuffle.seed = argv[++j];
} else if (pizza_io_cstr_compare(argv[j], "--count") == 0 && j + 1 < argc) {
pallet.shuffle.count = atoi(argv[++j]);
} else if (pizza_io_cstr_compare(argv[j], "--by") == 0 && j + 1 < argc) {
pallet.shuffle.by = argv[++j];
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
_show_subhelp_shuffle();
} else if (pizza_io_cstr_compare(argv[j], "--options") == 0) {
pizza_io_printf("{blue}Valid criteria for shuffling:{reset}\n");
for (int k = 0; VALID_CRITERIA[k] != null; k++) {
pizza_io_printf("{cyan} %s{reset}\n", VALID_CRITERIA[k]);
}
exit(EXIT_SUCCESS);
} else {
break;
}
}
} else if (strncmp(argv[i], "color=", 6) == 0) {
if (pizza_io_cstr_compare(argv[i] + 6, "enable") == 0) {
Expand Down