@@ -91,6 +91,7 @@ static void _show_subhelp_run(void) {
9191 pizza_io_printf ("{blue}Run command options:{reset}\n" );
9292 pizza_io_printf ("{cyan} --fail-fast Stop on the first failure{reset}\n" );
9393 pizza_io_printf ("{cyan} --only <test> Run only the specified test{reset}\n" );
94+ pizza_io_printf ("{cyan} --skip <test> Skip the specified test{reset}\n" );
9495 pizza_io_printf ("{cyan} --repeat <count> Repeat the test a specified number of times{reset}\n" );
9596 pizza_io_printf ("{cyan} --help Show help for run command{reset}\n" );
9697 exit (EXIT_SUCCESS );
@@ -201,6 +202,7 @@ static void _show_host(void) {
201202
202203fossil_pizza_pallet_t fossil_pizza_pallet_create (int argc , char * * argv ) {
203204 fossil_pizza_pallet_t pallet = {0 };
205+ int is_command = 0 ; // Variable to track if a command is being processed
204206
205207 // Parse command-line arguments
206208 for (int i = 1 ; i < argc ; i ++ ) {
@@ -213,32 +215,41 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
213215 } else if (pizza_io_cstr_compare (argv [i ], "--host" ) == 0 ) {
214216 _show_host ();
215217 } else if (pizza_io_cstr_compare (argv [i ], "run" ) == 0 ) {
218+ is_command = 1 ;
216219 pallet .run .fail_fast = 0 ;
217220 pallet .run .only = null ;
221+ pallet .run .skip = null ;
218222 pallet .run .repeat = 1 ;
219223
220224 for (int j = i + 1 ; j < argc ; j ++ ) {
225+ if (!is_command ) break ;
221226 if (pizza_io_cstr_compare (argv [j ], "--fail-fast" ) == 0 ) {
222227 pallet .run .fail_fast = 1 ;
223228 G_PIZZA_FAIL_FAST = 1 ;
224229 } else if (pizza_io_cstr_compare (argv [j ], "--only" ) == 0 && j + 1 < argc ) {
225230 pallet .run .only = argv [++ j ];
226- G_PIZZA_ONLY = pallet .run .only ;
231+ } else if (pizza_io_cstr_compare (argv [j ], "--skip" ) == 0 && j + 1 < argc ) {
232+ pallet .run .skip = argv [++ j ];
233+ G_PIZZA_SKIP = 1 ;
227234 } else if (pizza_io_cstr_compare (argv [j ], "--repeat" ) == 0 && j + 1 < argc ) {
228235 pallet .run .repeat = atoi (argv [++ j ]);
229236 G_PIZZA_REPEAT = pallet .run .repeat ;
237+ } else if (pizza_io_cstr_compare (argv [j ], "--threads" ) == 0 && j + 1 < argc ) {
238+ G_PIZZA_THREADS = atoi (argv [++ j ]);
230239 } else if (pizza_io_cstr_compare (argv [j ], "--help" ) == 0 ) {
231240 _show_subhelp_run ();
232241 } else {
233- break ;
242+ is_command = 0 ;
234243 }
235244 }
236245 } else if (pizza_io_cstr_compare (argv [i ], "filter" ) == 0 ) {
246+ is_command = 1 ;
237247 pallet .filter .test_name = null ;
238248 pallet .filter .suite_name = null ;
239249 pallet .filter .tag = null ;
240250
241251 for (int j = i + 1 ; j < argc ; j ++ ) {
252+ if (!is_command ) break ;
242253 if (pizza_io_cstr_compare (argv [j ], "--test-name" ) == 0 && j + 1 < argc ) {
243254 pallet .filter .test_name = argv [++ j ];
244255 } else if (pizza_io_cstr_compare (argv [j ], "--suite-name" ) == 0 && j + 1 < argc ) {
@@ -267,14 +278,16 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
267278 }
268279 exit (EXIT_SUCCESS );
269280 } else {
270- break ;
281+ is_command = 0 ;
271282 }
272283 }
273284 } else if (pizza_io_cstr_compare (argv [i ], "sort" ) == 0 ) {
285+ is_command = 1 ;
274286 pallet .sort .by = null ;
275287 pallet .sort .order = null ;
276288
277289 for (int j = i + 1 ; j < argc ; j ++ ) {
290+ if (!is_command ) break ;
278291 if (pizza_io_cstr_compare (argv [j ], "--by" ) == 0 && j + 1 < argc ) {
279292 const char * criteria = argv [++ j ];
280293 int is_valid_criteria = 0 ;
@@ -301,32 +314,34 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
301314 }
302315 exit (EXIT_SUCCESS );
303316 } else {
304- break ;
317+ is_command = 0 ;
305318 }
306319 }
307320 } else if (pizza_io_cstr_compare (argv [i ], "shuffle" ) == 0 ) {
321+ is_command = 1 ;
308322 pallet .shuffle .seed = null ;
309323 pallet .shuffle .count = 0 ;
310324 pallet .shuffle .by = null ;
311325
312326 for (int j = i + 1 ; j < argc ; j ++ ) {
313- if (pizza_io_cstr_compare (argv [j ], "--seed" ) == 0 && j + 1 < argc ) {
314- pallet .shuffle .seed = argv [++ j ];
315- } else if (pizza_io_cstr_compare (argv [j ], "--count" ) == 0 && j + 1 < argc ) {
316- pallet .shuffle .count = atoi (argv [++ j ]);
317- } else if (pizza_io_cstr_compare (argv [j ], "--by" ) == 0 && j + 1 < argc ) {
318- pallet .shuffle .by = argv [++ j ];
319- } else if (pizza_io_cstr_compare (argv [j ], "--help" ) == 0 ) {
320- _show_subhelp_shuffle ();
321- } else if (pizza_io_cstr_compare (argv [j ], "--options" ) == 0 ) {
322- pizza_io_printf ("{blue}Valid criteria for shuffling:{reset}\n" );
323- for (int k = 0 ; VALID_CRITERIA [k ] != null ; k ++ ) {
324- pizza_io_printf ("{cyan} %s{reset}\n" , VALID_CRITERIA [k ]);
327+ if (!is_command ) break ;
328+ if (pizza_io_cstr_compare (argv [j ], "--seed" ) == 0 && j + 1 < argc ) {
329+ pallet .shuffle .seed = argv [++ j ];
330+ } else if (pizza_io_cstr_compare (argv [j ], "--count" ) == 0 && j + 1 < argc ) {
331+ pallet .shuffle .count = atoi (argv [++ j ]);
332+ } else if (pizza_io_cstr_compare (argv [j ], "--by" ) == 0 && j + 1 < argc ) {
333+ pallet .shuffle .by = argv [++ j ];
334+ } else if (pizza_io_cstr_compare (argv [j ], "--help" ) == 0 ) {
335+ _show_subhelp_shuffle ();
336+ } else if (pizza_io_cstr_compare (argv [j ], "--options" ) == 0 ) {
337+ pizza_io_printf ("{blue}Valid criteria for shuffling:{reset}\n" );
338+ for (int k = 0 ; VALID_CRITERIA [k ] != null ; k ++ ) {
339+ pizza_io_printf ("{cyan} %s{reset}\n" , VALID_CRITERIA [k ]);
340+ }
341+ exit (EXIT_SUCCESS );
342+ } else {
343+ is_command = 0 ;
325344 }
326- exit (EXIT_SUCCESS );
327- } else {
328- break ;
329- }
330345 }
331346 } else if (strncmp (argv [i ], "color=" , 6 ) == 0 ) {
332347 if (pizza_io_cstr_compare (argv [i ] + 6 , "enable" ) == 0 ) {
@@ -363,7 +378,6 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
363378 if (i + 1 < argc && pizza_io_cstr_compare (argv [i + 1 ], "--help" ) == 0 ) {
364379 _show_help ();
365380 }
366-
367381 } else if (strncmp (argv [i ], "theme=" , 6 ) == 0 ) {
368382 const char * theme_str = argv [i ] + 6 ;
369383 if (pizza_io_cstr_compare (theme_str , "fossil" ) == 0 ) {
@@ -387,7 +401,6 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
387401 } else if (pizza_io_cstr_compare (theme_str , "unity" ) == 0 ) {
388402 pallet .theme = PIZZA_THEME_UNITY ;
389403 G_PIZZA_THEME = PIZZA_THEME_UNITY ;
390-
391404 }
392405 } else if (pizza_io_cstr_compare (argv [i ], "theme" ) == 0 ) {
393406 if (i + 1 < argc && pizza_io_cstr_compare (argv [i + 1 ], "--help" ) == 0 ) {
@@ -401,7 +414,7 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
401414 } else if (pizza_io_cstr_compare (verbose_str , "ci" ) == 0 ) {
402415 pallet .verbose = PIZZA_VERBOSE_CI ;
403416 G_PIZZA_VERBOSE = PIZZA_VERBOSE_CI ;
404- } else if (pizza_io_cstr_compare (verbose_str , "doge" ) == 0 ) { // means verbose for Pizza Test
417+ } else if (pizza_io_cstr_compare (verbose_str , "doge" ) == 0 ) {
405418 pallet .verbose = PIZZA_VERBOSE_DOGE ;
406419 G_PIZZA_VERBOSE = PIZZA_VERBOSE_DOGE ;
407420 }
@@ -416,9 +429,6 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
416429 _show_help ();
417430 exit (EXIT_SUCCESS );
418431 }
419- } else {
420- pizza_io_printf ("{red}Error: Unknown command or option '%s'.{reset}\n" , argv [i ]);
421- exit (EXIT_FAILURE );
422432 }
423433 }
424434
0 commit comments