Commit bd4dc911847d0cde7a6b41dfa626a85aab213baf
1 parent
afa7a456
add extra test
Showing
2 changed files
with
15 additions
and
1 deletions
include/CLI/App.hpp
| ... | ... | @@ -1389,7 +1389,7 @@ class App { |
| 1389 | 1389 | } |
| 1390 | 1390 | } |
| 1391 | 1391 | |
| 1392 | - /// Return True if a help flag detected (checks all parents) | |
| 1392 | + /// Return True if a help flag detected (checks all parents) (only run if help called before subcommand) | |
| 1393 | 1393 | bool _any_help_flag() const { |
| 1394 | 1394 | bool result = false; |
| 1395 | 1395 | const Option *help_ptr = get_help_ptr(); | ... | ... |
tests/SubcommandTest.cpp
| ... | ... | @@ -438,6 +438,8 @@ struct SubcommandProgram : public TApp { |
| 438 | 438 | int count; |
| 439 | 439 | |
| 440 | 440 | SubcommandProgram() { |
| 441 | + app.set_help_all_flag("--help-all"); | |
| 442 | + | |
| 441 | 443 | start = app.add_subcommand("start", "Start prog"); |
| 442 | 444 | stop = app.add_subcommand("stop", "Stop prog"); |
| 443 | 445 | |
| ... | ... | @@ -541,6 +543,18 @@ TEST_F(SubcommandProgram, HelpOrder) { |
| 541 | 543 | EXPECT_THROW(run(), CLI::CallForHelp); |
| 542 | 544 | } |
| 543 | 545 | |
| 546 | +TEST_F(SubcommandProgram, HelpAllOrder) { | |
| 547 | + | |
| 548 | + args = {"--help-all"}; | |
| 549 | + EXPECT_THROW(run(), CLI::CallForAllHelp); | |
| 550 | + | |
| 551 | + args = {"start", "--help-all"}; | |
| 552 | + EXPECT_THROW(run(), CLI::CallForAllHelp); | |
| 553 | + | |
| 554 | + args = {"--help-all", "start"}; | |
| 555 | + EXPECT_THROW(run(), CLI::CallForAllHelp); | |
| 556 | +} | |
| 557 | + | |
| 544 | 558 | TEST_F(SubcommandProgram, Callbacks) { |
| 545 | 559 | |
| 546 | 560 | start->callback([]() { throw CLI::Success(); }); | ... | ... |