start option groups
This commit is contained in:
parent
fd3d4bb2e7
commit
2bf1060d0b
@ -129,9 +129,9 @@ namespace cxxopts
|
||||
}
|
||||
|
||||
OptionAdder
|
||||
Options::add_options()
|
||||
Options::add_options(std::string group)
|
||||
{
|
||||
return OptionAdder(*this);
|
||||
return OptionAdder(*this, std::move(group));
|
||||
}
|
||||
|
||||
OptionAdder&
|
||||
@ -153,7 +153,7 @@ OptionAdder::operator()
|
||||
const auto& s = result[2];
|
||||
const auto& l = result[3];
|
||||
|
||||
m_options.add_option(s.str(), l.str(), desc, value);
|
||||
m_options.add_option(m_group, s.str(), l.str(), desc, value);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -342,6 +342,7 @@ Options::parse(int& argc, char**& argv)
|
||||
void
|
||||
Options::add_option
|
||||
(
|
||||
const std::string& group,
|
||||
const std::string& s,
|
||||
const std::string& l,
|
||||
const std::string& desc,
|
||||
@ -361,7 +362,7 @@ Options::add_option
|
||||
}
|
||||
|
||||
//add the help details
|
||||
auto& options = m_help[""];
|
||||
auto& options = m_help[group];
|
||||
options.push_back(HelpDetails{s, l, desc, value->has_arg()});
|
||||
}
|
||||
|
||||
|
||||
@ -333,11 +333,12 @@ namespace cxxopts
|
||||
parse(int& argc, char**& argv);
|
||||
|
||||
OptionAdder
|
||||
add_options();
|
||||
add_options(std::string group = "");
|
||||
|
||||
void
|
||||
add_option
|
||||
(
|
||||
const std::string& group,
|
||||
const std::string& s,
|
||||
const std::string& l,
|
||||
const std::string& desc,
|
||||
@ -420,8 +421,8 @@ namespace cxxopts
|
||||
{
|
||||
public:
|
||||
|
||||
OptionAdder(Options& options)
|
||||
: m_options(options)
|
||||
OptionAdder(Options& options, std::string group)
|
||||
: m_options(options), m_group(std::move(group))
|
||||
{
|
||||
}
|
||||
|
||||
@ -436,6 +437,7 @@ namespace cxxopts
|
||||
|
||||
private:
|
||||
Options& m_options;
|
||||
std::string m_group;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user