From cb906d1aabfa44f97f035950d8f5cd50e754510d Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 22 Aug 2017 14:18:30 -0500 Subject: [PATCH] Fix #23: Respect fallthrough_ in _valid_subcommand _valid_subcommand checks whether its argument appears to be a valid subcommand name or not; however, if it doesn't recognize the name, it always checks if its parent does. As described in in issue #23, this can cause incorrect behavior. To avoid this, check if fallthrough is disabled first, and do not consult the parent's known subcommands if fallthrough is disabled. --- include/CLI/App.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 02863cf1..54f4e5c8 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -857,7 +857,7 @@ class App { for(const App_p &com : subcommands_) if(com->check_name(current)) return true; - if(parent_ != nullptr) + if(parent_ != nullptr && fallthrough_) return parent_->_valid_subcommand(current); else return false;