diff --git a/CHANGELOG.md b/CHANGELOG.md index a9cabab4..8a1cae53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +- add mechanism to allow option groups to be hidden and all options be + considered part of the parent for help display + ## Version 2.4: Unicode and TOML support This version adds Unicode support, support for TOML standard including multiline diff --git a/README.md b/README.md index 0f322991..19c855fb 100644 --- a/README.md +++ b/README.md @@ -1205,7 +1205,17 @@ auto hidden_group=app.add_option_group(""); ``` will create a group such that no options in that group are displayed in the help -string. +string. For the purposes of help display, if the option group name starts with a +'+' it is treated as if it were not in a group for help and get_options. For +example: + +```cpp +auto added_group=app.add_option_group("+sub"); +``` + +In this case the help output will not reference the option group and options +inside of it will be treated for most purposes as if they were part of the +parent. ### Configuration file diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 940b858b..e3fcbd52 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -1340,6 +1340,11 @@ class Option_group : public App { : App(std::move(group_description), "", parent) { group(group_name); // option groups should have automatic fallthrough + if(group_name.empty() || group_name.front() == '+') { + // help will not be used by default in these contexts + set_help_flag(""); + set_help_all_flag(""); + } } using App::add_option; /// Add an existing option to the Option_group diff --git a/include/CLI/impl/App_inl.hpp b/include/CLI/impl/App_inl.hpp index 43b9dfe4..a06955c4 100644 --- a/include/CLI/impl/App_inl.hpp +++ b/include/CLI/impl/App_inl.hpp @@ -784,7 +784,14 @@ CLI11_INLINE std::vector App::get_options(const std::functionget_name().empty() && !subc->get_group().empty() && subc->get_group().front() == '+') { + std::vector subcopts = subc->get_options(filter); + options.insert(options.end(), subcopts.begin(), subcopts.end()); + } + } return options; } @@ -798,7 +805,13 @@ CLI11_INLINE std::vector