mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-30 04:33:53 +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.
|
* `->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.
|
* `->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.
|
* `->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).
|
* `->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
|
* `->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.
|
* `->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
|
* `.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.
|
* `.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.
|
* `.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.
|
> 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_)
|
for(const Option_p &opt : options_)
|
||||||
if(opt->get_positional()) {
|
if(opt->get_positional()) {
|
||||||
// A hidden positional should still show up in the usage statement
|
// 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;
|
// continue;
|
||||||
out << " " << opt->help_positional();
|
out << " " << opt->help_positional();
|
||||||
if(opt->_has_help_positional())
|
if(opt->_has_help_positional())
|
||||||
@ -870,8 +870,8 @@ class App {
|
|||||||
if(pos) {
|
if(pos) {
|
||||||
out << std::endl << "Positionals:" << std::endl;
|
out << std::endl << "Positionals:" << std::endl;
|
||||||
for(const Option_p &opt : options_) {
|
for(const Option_p &opt : options_) {
|
||||||
if(detail::to_lower(opt->get_group()) == "hidden")
|
if(detail::to_lower(opt->get_group()).empty())
|
||||||
continue;
|
continue; // Hidden
|
||||||
if(opt->_has_help_positional())
|
if(opt->_has_help_positional())
|
||||||
detail::format_help(out, opt->help_pname(), opt->get_description(), wid);
|
detail::format_help(out, opt->help_pname(), opt->get_description(), wid);
|
||||||
}
|
}
|
||||||
@ -880,8 +880,8 @@ class App {
|
|||||||
// Options
|
// Options
|
||||||
if(npos) {
|
if(npos) {
|
||||||
for(const std::string &group : groups) {
|
for(const std::string &group : groups) {
|
||||||
if(detail::to_lower(group) == "hidden")
|
if(detail::to_lower(group).empty())
|
||||||
continue;
|
continue; // Hidden
|
||||||
out << std::endl << group << ":" << std::endl;
|
out << std::endl << group << ":" << std::endl;
|
||||||
for(const Option_p &opt : options_) {
|
for(const Option_p &opt : options_) {
|
||||||
if(opt->nonpositional() && opt->get_group() == group)
|
if(opt->nonpositional() && opt->get_group() == group)
|
||||||
@ -896,7 +896,7 @@ class App {
|
|||||||
for(const App_p &com : subcommands_) {
|
for(const App_p &com : subcommands_) {
|
||||||
const std::string &group_key = detail::to_lower(com->get_group());
|
const std::string &group_key = detail::to_lower(com->get_group());
|
||||||
if(group_key.empty() || subcmd_groups_seen.count(group_key) != 0)
|
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);
|
subcmd_groups_seen.insert(group_key);
|
||||||
out << std::endl << com->get_group() << ":" << std::endl;
|
out << std::endl << com->get_group() << ":" << std::endl;
|
||||||
|
@ -56,9 +56,9 @@ TEST(THelp, Hidden) {
|
|||||||
CLI::App app{"My prog"};
|
CLI::App app{"My prog"};
|
||||||
|
|
||||||
std::string x;
|
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;
|
std::string y;
|
||||||
app.add_option("--another", y)->group("Hidden");
|
app.add_option("--another", y)->group("");
|
||||||
|
|
||||||
std::string help = app.help();
|
std::string help = app.help();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user