diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 7309deb..4b207e1 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -1389,7 +1389,7 @@ class App { } } - /// Return True if a help flag detected (checks all parents) + /// Return True if a help flag detected (checks all parents) (only run if help called before subcommand) bool _any_help_flag() const { bool result = false; const Option *help_ptr = get_help_ptr(); diff --git a/tests/SubcommandTest.cpp b/tests/SubcommandTest.cpp index bc5d8ca..e752f4f 100644 --- a/tests/SubcommandTest.cpp +++ b/tests/SubcommandTest.cpp @@ -438,6 +438,8 @@ struct SubcommandProgram : public TApp { int count; SubcommandProgram() { + app.set_help_all_flag("--help-all"); + start = app.add_subcommand("start", "Start prog"); stop = app.add_subcommand("stop", "Stop prog"); @@ -541,6 +543,18 @@ TEST_F(SubcommandProgram, HelpOrder) { EXPECT_THROW(run(), CLI::CallForHelp); } +TEST_F(SubcommandProgram, HelpAllOrder) { + + args = {"--help-all"}; + EXPECT_THROW(run(), CLI::CallForAllHelp); + + args = {"start", "--help-all"}; + EXPECT_THROW(run(), CLI::CallForAllHelp); + + args = {"--help-all", "start"}; + EXPECT_THROW(run(), CLI::CallForAllHelp); +} + TEST_F(SubcommandProgram, Callbacks) { start->callback([]() { throw CLI::Success(); });