Skip to content

Commit bd4dc91

Browse files
committed
add extra test
1 parent afa7a45 commit bd4dc91

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

include/CLI/App.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ class App {
13891389
}
13901390
}
13911391

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)
13931393
bool _any_help_flag() const {
13941394
bool result = false;
13951395
const Option *help_ptr = get_help_ptr();

tests/SubcommandTest.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ struct SubcommandProgram : public TApp {
438438
int count;
439439

440440
SubcommandProgram() {
441+
app.set_help_all_flag("--help-all");
442+
441443
start = app.add_subcommand("start", "Start prog");
442444
stop = app.add_subcommand("stop", "Stop prog");
443445

@@ -541,6 +543,18 @@ TEST_F(SubcommandProgram, HelpOrder) {
541543
EXPECT_THROW(run(), CLI::CallForHelp);
542544
}
543545

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+
544558
TEST_F(SubcommandProgram, Callbacks) {
545559

546560
start->callback([]() { throw CLI::Success(); });

0 commit comments

Comments
 (0)