| 337 | } |
| 338 | |
| 339 | static int parse_subcommand__cmd(int argc, const char **argv, |
| 340 | enum parse_opt_flags test_flags) |
| 341 | { |
| 342 | const char *usage[] = { |
| 343 | "<...> cmd subcmd-one", |
| 344 | "<...> cmd subcmd-two", |
| 345 | NULL |
| 346 | }; |
| 347 | parse_opt_subcommand_fn *fn = NULL; |
| 348 | int opt = 0; |
| 349 | struct option options[] = { |
| 350 | OPT_SUBCOMMAND("subcmd-one", &fn, subcmd_one), |
| 351 | OPT_SUBCOMMAND("subcmd-two", &fn, subcmd_two), |
| 352 | OPT_INTEGER('o', "opt", &opt, "an integer option"), |
| 353 | OPT_END() |
| 354 | }; |
| 355 | |
| 356 | if (test_flags & PARSE_OPT_SUBCOMMAND_OPTIONAL) |
| 357 | fn = subcmd_one; |
| 358 | argc = parse_options(argc, argv, NULL, options, usage, test_flags); |
| 359 | |
| 360 | printf("opt: %d\n", opt); |
| 361 | |
| 362 | return fn(argc, argv, NULL, NULL); |
| 363 | } |
| 364 | |
| 365 | int cmd__parse_subcommand(int argc, const char **argv) |
| 366 | { |
no test coverage detected