Commit cb906d1aabfa44f97f035950d8f5cd50e754510d

Authored by Nathan Hourt
Committed by GitHub
1 parent 363571be

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.
Showing 1 changed file with 1 additions and 1 deletions
include/CLI/App.hpp
... ... @@ -857,7 +857,7 @@ class App {
857 857 for(const App_p &com : subcommands_)
858 858 if(com->check_name(current))
859 859 return true;
860   - if(parent_ != nullptr)
  860 + if(parent_ != nullptr && fallthrough_)
861 861 return parent_->_valid_subcommand(current);
862 862 else
863 863 return false;
... ...