diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index e1d4ef8e..cd9804ed 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -537,12 +537,9 @@ public: /// Check with name instead of pointer bool got_subcommand(std::string name) const { - for(const auto subcomptr : selected_subcommands_) - if(subcomptr->check_name(name)) - return true; for(const App_p &subcomptr : subcommands_) if(subcomptr->check_name(name)) - return false; + return got_subcommand(subcomptr.get()); throw CLI::OptionNotFound(name); } diff --git a/tests/SubcommandTest.cpp b/tests/SubcommandTest.cpp index 3fae020f..4d371807 100644 --- a/tests/SubcommandTest.cpp +++ b/tests/SubcommandTest.cpp @@ -34,7 +34,7 @@ TEST_F(TApp, MultiSubFallthrough) { args = {"sub1", "sub2"}; run(); EXPECT_TRUE(app.got_subcommand("sub1")); - EXPECT_TRUE(app.got_subcommand(sub1); + EXPECT_TRUE(app.got_subcommand(sub1)); EXPECT_TRUE(app.got_subcommand("sub2")); app.reset();