add_options variant with initializer list
This commit is contained in:
parent
e6858d3429
commit
c93be2ee3c
@ -1220,6 +1220,14 @@ namespace cxxopts
|
|||||||
|
|
||||||
std::vector<KeyValue> m_sequential;
|
std::vector<KeyValue> m_sequential;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Option
|
||||||
|
{
|
||||||
|
std::string opts;
|
||||||
|
std::string desc;
|
||||||
|
std::shared_ptr<const Value> value = ::cxxopts::value<bool>();
|
||||||
|
std::string arg_help = "";
|
||||||
|
};
|
||||||
|
|
||||||
class Options
|
class Options
|
||||||
{
|
{
|
||||||
@ -1272,6 +1280,13 @@ namespace cxxopts
|
|||||||
|
|
||||||
OptionAdder
|
OptionAdder
|
||||||
add_options(std::string group = "");
|
add_options(std::string group = "");
|
||||||
|
|
||||||
|
void
|
||||||
|
add_options
|
||||||
|
(
|
||||||
|
const std::string& group,
|
||||||
|
std::initializer_list<Option> options
|
||||||
|
);
|
||||||
|
|
||||||
void
|
void
|
||||||
add_option
|
add_option
|
||||||
@ -1511,6 +1526,21 @@ ParseResult::ParseResult
|
|||||||
parse(argc, argv);
|
parse(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void
|
||||||
|
Options::add_options
|
||||||
|
(
|
||||||
|
const std::string &group,
|
||||||
|
std::initializer_list<Option> options
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OptionAdder option_adder(*this, group);
|
||||||
|
for (const auto &option: options)
|
||||||
|
{
|
||||||
|
option_adder(option.opts, option.desc, option.value, option.arg_help);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
OptionAdder
|
OptionAdder
|
||||||
Options::add_options(std::string group)
|
Options::add_options(std::string group)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user