| 421 | } |
| 422 | |
| 423 | struct ManyGroups : public TApp { |
| 424 | |
| 425 | CLI::Option_group *main{nullptr}; |
| 426 | CLI::Option_group *g1{nullptr}; |
| 427 | CLI::Option_group *g2{nullptr}; |
| 428 | CLI::Option_group *g3{nullptr}; |
| 429 | std::string name1{}; |
| 430 | std::string name2{}; |
| 431 | std::string name3{}; |
| 432 | std::string val1{}; |
| 433 | std::string val2{}; |
| 434 | std::string val3{}; |
| 435 | |
| 436 | ManyGroups(const ManyGroups &) = delete; |
| 437 | ManyGroups &operator=(const ManyGroups &) = delete; |
| 438 | |
| 439 | ManyGroups() { |
| 440 | main = app.add_option_group("main", "the main outer group"); |
| 441 | g1 = main->add_option_group("g1", "group1 description"); |
| 442 | g2 = main->add_option_group("g2", "group2 description"); |
| 443 | g3 = main->add_option_group("g3", "group3 description"); |
| 444 | g1->add_option("--name1", name1)->required(); |
| 445 | g1->add_option("--val1", val1); |
| 446 | g2->add_option("--name2", name2)->required(); |
| 447 | g2->add_option("--val2", val2); |
| 448 | g3->add_option("--name3", name3)->required(); |
| 449 | g3->add_option("--val3", val3); |
| 450 | } |
| 451 | |
| 452 | void remove_required() { // NOLINT(readability-make-member-function-const) |
| 453 | g1->get_option("--name1")->required(false); |
| 454 | g2->get_option("--name2")->required(false); |
| 455 | g3->get_option("--name3")->required(false); |
| 456 | g1->required(false); |
| 457 | g2->required(false); |
| 458 | g3->required(false); |
| 459 | } |
| 460 | }; |
| 461 | |
| 462 | TEST_CASE_METHOD(ManyGroups, "SingleGroup", "[optiongroup]") { |
| 463 | // only 1 group can be used |
nothing calls this directly
no outgoing calls
no test coverage detected