Commit 7130f076 authored by Mathieu Giraud's avatar Mathieu Giraud

lib/CLI11.hpp: -> level()

Some options will be not always displayed in the help message.
Replays da89488c.
parent 4a79a4c2
......@@ -1105,6 +1105,9 @@ template <typename CRTP> class OptionBase {
/// True if this is a required option
bool required_{false};
/// >= 2 if this is an advanced option
int help_level_{1};
/// Ignore the case when matching (option, not value)
bool ignore_case_{false};
......@@ -1138,6 +1141,12 @@ template <typename CRTP> class OptionBase {
return static_cast<CRTP *>(this);
}
/// Set the help level
CRTP *level(int value = 2) {
help_level_ = value;
return static_cast<CRTP *>(this);
}
/// Support Plumbum term
CRTP *mandatory(bool value = true) { return required(value); }
......@@ -2615,7 +2624,7 @@ class App {
}
/// Makes a help message, with a column wid for column 1
std::string help(size_t wid = 30, std::string prev = "") const {
std::string help(size_t wid = 30, std::string prev = "", int help_level = 1) const {
// Delegate to subcommand if needed
if(prev.empty())
prev = name_;
......@@ -2686,7 +2695,7 @@ class App {
continue; // Hidden
out << std::endl << group << ":" << std::endl;
for(const Option_p &opt : options_) {
if(opt->nonpositional() && opt->get_group() == group)
if(opt->nonpositional() && opt->get_group() == group && opt->help_level_ <= help_level)
detail::format_help(out, opt->help_name(true), opt->get_description(), wid);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment