1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-01 13:13:53 +00:00

Issue cleanup (#1059)

Fix docstring related to #1052 
Fix config_to_string with defaults #1007

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Philip Top 2024-07-29 05:32:11 -07:00 committed by GitHub
parent 7be1740521
commit b038a403ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 9 deletions

View File

@ -1027,8 +1027,9 @@ functionality for tricky parsing situations.
- Added `app.parse_order()` with original parse order
([#13](https://github.com/CLIUtils/CLI11/issues/13),
[#16](https://github.com/CLIUtils/CLI11/pull/16))
- Added `prefix_command()`, which is like `allow_extras` but instantly stops and
returns. ([#8](https://github.com/CLIUtils/CLI11/issues/8),
- Added `prefix_command()`, which is like `allow_extras` but ceases processing
and puts all remaining args in the remaining_args structure.
[#8](https://github.com/CLIUtils/CLI11/issues/8),
[#17](https://github.com/CLIUtils/CLI11/pull/17))
- Removed Windows warning ([#10](https://github.com/CLIUtils/CLI11/issues/10),
[#20](https://github.com/CLIUtils/CLI11/pull/20))

View File

@ -1010,8 +1010,9 @@ option_groups. These are:
- `.allow_extras()`: Do not throw an error if extra arguments are left over.
- `.positionals_at_end()`: Specify that positional arguments occur as the last
arguments and throw an error if an unexpected positional is encountered.
- `.prefix_command()`: Like `allow_extras`, but stop immediately on the first
unrecognized item. It is ideal for allowing your app or subcommand to be a
- `.prefix_command()`: Like `allow_extras`, but stop processing immediately on
the first unrecognized item. All subsequent arguments are placed in the
remaining_arg list. It is ideal for allowing your app or subcommand to be a
"prefix" to calling another app.
- `.usage(message)`: 🆕 Replace text to appear at the start of the help string
after description.

View File

@ -110,7 +110,7 @@ class App {
/// if error error on an extra argument, and if capture feed it to the app
config_extras_mode allow_config_extras_{config_extras_mode::ignore};
/// If true, return immediately on an unrecognized option (implies allow_extras) INHERITABLE
/// If true, cease processing on an unrecognized option (implies allow_extras) INHERITABLE
bool prefix_command_{false};
/// If set to true the name was automatically generated from the command line vs a user set name
@ -442,9 +442,10 @@ class App {
return this;
}
/// Do not parse anything after the first unrecognized option and return
App *prefix_command(bool allow = true) {
prefix_command_ = allow;
/// Do not parse anything after the first unrecognized option (if true) all remaining arguments are stored in
/// remaining args
App *prefix_command(bool is_prefix = true) {
prefix_command_ = is_prefix;
return this;
}

View File

@ -583,7 +583,7 @@ ConfigBase::to_config(const App *app, bool default_also, bool write_description,
std::string subname = subcom->get_name();
clean_name_string(subname, keyChars);
if(subcom->get_configurable() && app->got_subcommand(subcom)) {
if(subcom->get_configurable() && (default_also || app->got_subcommand(subcom))) {
if(!prefix.empty() || app->get_parent() == nullptr) {
out << '[' << prefix << subname << "]\n";