From bd4dc911847d0cde7a6b41dfa626a85aab213baf Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sat, 24 Nov 2018 23:40:18 +0200 Subject: [PATCH] add extra test --- include/CLI/App.hpp | 2 +- tests/SubcommandTest.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 7309deb3..4b207e13 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 bc5d8ca0..e752f4f2 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(); });