mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 12:13:52 +00:00
Dropping hidden keyword, just use empty string
This commit is contained in:
parent
a133e9cc06
commit
92a3cacd59
@ -153,7 +153,7 @@ The add commands return a pointer to an internally stored `Option`. If you set t
|
||||
* `->requires(opt)`: This option requires another option to also be present, opt is an `Option` pointer.
|
||||
* `->excludes(opt)`: This option cannot be given with `opt` present, opt is an `Option` pointer.
|
||||
* `->envname(name)`: Gets the value from the environment if present and not passed on the command line.
|
||||
* `->group(name)`: The help group to put the option in. No effect for positional options. Defaults to `"Options"`. `"Hidden"` will not show up in the help print.
|
||||
* `->group(name)`: The help group to put the option in. No effect for positional options. Defaults to `"Options"`. `""` will not show up in the help print (hidden).
|
||||
* `->ignore_case()`: Ignore the case on the command line (also works on subcommands, does not affect arguments).
|
||||
* `->take_last()`: Only take the last option/flag given on the command line, automatically true for bool flags
|
||||
* `->check(CLI::ExistingFile)`: Requires that the file exists if given.
|
||||
@ -211,6 +211,7 @@ There are several options that are supported on the main app and subcommands. Th
|
||||
* `.allow_extras()`: Do not throw an error if extra arguments are left over
|
||||
* `.prefix_command()`: Like `allow_extras`, but stop immediately on the first unrecognised item. It is ideal for allowing your app or subcommand to be a "prefix" to calling another app.
|
||||
* `.set_footer(message)`: Set text to appear at the bottom of the help string.
|
||||
* `.group(name)`: Set a group name, defaults to `"Subcommands"`. Setting `""` will be hide the subcommand.
|
||||
|
||||
> Note: if you have a fixed number of required positional options, that will match before subcommand names.
|
||||
|
||||
|
@ -850,7 +850,7 @@ class App {
|
||||
for(const Option_p &opt : options_)
|
||||
if(opt->get_positional()) {
|
||||
// A hidden positional should still show up in the usage statement
|
||||
// if(detail::to_lower(opt->get_group()) == "hidden")
|
||||
// if(detail::to_lower(opt->get_group()).empty())
|
||||
// continue;
|
||||
out << " " << opt->help_positional();
|
||||
if(opt->_has_help_positional())
|
||||
@ -870,8 +870,8 @@ class App {
|
||||
if(pos) {
|
||||
out << std::endl << "Positionals:" << std::endl;
|
||||
for(const Option_p &opt : options_) {
|
||||
if(detail::to_lower(opt->get_group()) == "hidden")
|
||||
continue;
|
||||
if(detail::to_lower(opt->get_group()).empty())
|
||||
continue; // Hidden
|
||||
if(opt->_has_help_positional())
|
||||
detail::format_help(out, opt->help_pname(), opt->get_description(), wid);
|
||||
}
|
||||
@ -880,8 +880,8 @@ class App {
|
||||
// Options
|
||||
if(npos) {
|
||||
for(const std::string &group : groups) {
|
||||
if(detail::to_lower(group) == "hidden")
|
||||
continue;
|
||||
if(detail::to_lower(group).empty())
|
||||
continue; // Hidden
|
||||
out << std::endl << group << ":" << std::endl;
|
||||
for(const Option_p &opt : options_) {
|
||||
if(opt->nonpositional() && opt->get_group() == group)
|
||||
@ -896,7 +896,7 @@ class App {
|
||||
for(const App_p &com : subcommands_) {
|
||||
const std::string &group_key = detail::to_lower(com->get_group());
|
||||
if(group_key.empty() || subcmd_groups_seen.count(group_key) != 0)
|
||||
continue;
|
||||
continue; // Hidden or not in a group
|
||||
|
||||
subcmd_groups_seen.insert(group_key);
|
||||
out << std::endl << com->get_group() << ":" << std::endl;
|
||||
|
@ -56,9 +56,9 @@ TEST(THelp, Hidden) {
|
||||
CLI::App app{"My prog"};
|
||||
|
||||
std::string x;
|
||||
app.add_option("something", x, "My option here")->group("Hidden");
|
||||
app.add_option("something", x, "My option here")->group("");
|
||||
std::string y;
|
||||
app.add_option("--another", y)->group("Hidden");
|
||||
app.add_option("--another", y)->group("");
|
||||
|
||||
std::string help = app.help();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user