Merge branch 'master' into default_values
Conflicts: src/cxxopts.hpp src/example.cpp
This commit is contained in:
commit
9a2749f692
@ -594,6 +594,7 @@ namespace cxxopts
|
|||||||
bool has_arg;
|
bool has_arg;
|
||||||
bool has_default;
|
bool has_default;
|
||||||
std::string default_value;
|
std::string default_value;
|
||||||
|
std::string arg_help;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HelpGroupDetails
|
struct HelpGroupDetails
|
||||||
@ -629,7 +630,8 @@ namespace cxxopts
|
|||||||
const std::string& s,
|
const std::string& s,
|
||||||
const std::string& l,
|
const std::string& l,
|
||||||
std::string desc,
|
std::string desc,
|
||||||
std::shared_ptr<const Value> value
|
std::shared_ptr<const Value> value,
|
||||||
|
std::string arg_help
|
||||||
);
|
);
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -734,7 +736,8 @@ namespace cxxopts
|
|||||||
const std::string& opts,
|
const std::string& opts,
|
||||||
const std::string& desc,
|
const std::string& desc,
|
||||||
std::shared_ptr<const Value> value
|
std::shared_ptr<const Value> value
|
||||||
= ::cxxopts::value<bool>()
|
= ::cxxopts::value<bool>(),
|
||||||
|
std::string arg_help = ""
|
||||||
);
|
);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -786,7 +789,14 @@ namespace cxxopts
|
|||||||
|
|
||||||
if (o.has_arg)
|
if (o.has_arg)
|
||||||
{
|
{
|
||||||
result += " arg";
|
if (o.arg_help.size() != 0)
|
||||||
|
{
|
||||||
|
result += " " + toLocalString(o.arg_help);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += " arg";
|
||||||
|
}
|
||||||
|
|
||||||
if (o.has_default)
|
if (o.has_default)
|
||||||
{
|
{
|
||||||
@ -865,7 +875,8 @@ OptionAdder::operator()
|
|||||||
(
|
(
|
||||||
const std::string& opts,
|
const std::string& opts,
|
||||||
const std::string& desc,
|
const std::string& desc,
|
||||||
std::shared_ptr<const Value> value
|
std::shared_ptr<const Value> value,
|
||||||
|
std::string arg_help
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::match_results<const char*> result;
|
std::match_results<const char*> result;
|
||||||
@ -879,7 +890,8 @@ OptionAdder::operator()
|
|||||||
const auto& s = result[2];
|
const auto& s = result[2];
|
||||||
const auto& l = result[3];
|
const auto& l = result[3];
|
||||||
|
|
||||||
m_options.add_option(m_group, s.str(), l.str(), desc, value);
|
m_options.add_option(m_group, s.str(), l.str(), desc, value,
|
||||||
|
std::move(arg_help));
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -1100,7 +1112,8 @@ Options::add_option
|
|||||||
const std::string& s,
|
const std::string& s,
|
||||||
const std::string& l,
|
const std::string& l,
|
||||||
std::string desc,
|
std::string desc,
|
||||||
std::shared_ptr<const Value> value
|
std::shared_ptr<const Value> value,
|
||||||
|
std::string arg_help
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
auto stringDesc = toLocalString(std::move(desc));
|
auto stringDesc = toLocalString(std::move(desc));
|
||||||
@ -1120,7 +1133,8 @@ Options::add_option
|
|||||||
auto& options = m_help[group];
|
auto& options = m_help[group];
|
||||||
|
|
||||||
options.options.emplace_back(HelpOptionDetails{s, l, stringDesc,
|
options.options.emplace_back(HelpOptionDetails{s, l, stringDesc,
|
||||||
value->has_arg(), value->has_default(), value->get_default_value()});
|
value->has_arg(), value->has_default(), value->get_default_value(),
|
||||||
|
std::move(arg_help)});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@ -37,7 +37,7 @@ int main(int argc, char* argv[])
|
|||||||
options.add_options()
|
options.add_options()
|
||||||
("a,apple", "an apple", cxxopts::value<bool>(apple))
|
("a,apple", "an apple", cxxopts::value<bool>(apple))
|
||||||
("b,bob", "Bob")
|
("b,bob", "Bob")
|
||||||
("f,file", "File", cxxopts::value<std::vector<std::string>>())
|
("f,file", "File", cxxopts::value<std::vector<std::string>>(), "FILE")
|
||||||
("o,output", "Output file", cxxopts::value<std::string>()
|
("o,output", "Output file", cxxopts::value<std::string>()
|
||||||
->default_value("a.out")->implicit_value("b.def"))
|
->default_value("a.out")->implicit_value("b.def"))
|
||||||
("positional",
|
("positional",
|
||||||
@ -46,7 +46,7 @@ int main(int argc, char* argv[])
|
|||||||
("long-description",
|
("long-description",
|
||||||
"thisisareallylongwordthattakesupthewholelineandcannotbebrokenataspace")
|
"thisisareallylongwordthattakesupthewholelineandcannotbebrokenataspace")
|
||||||
("help", "Print help")
|
("help", "Print help")
|
||||||
("int", "An integer", cxxopts::value<int>())
|
("int", "An integer", cxxopts::value<int>(), "N")
|
||||||
("option_that_is_too_long_for_the_help", "A very long option")
|
("option_that_is_too_long_for_the_help", "A very long option")
|
||||||
#ifdef CXXOPTS_USE_UNICODE
|
#ifdef CXXOPTS_USE_UNICODE
|
||||||
("unicode", u8"A help option with non-ascii: à. Here the size of the"
|
("unicode", u8"A help option with non-ascii: à. Here the size of the"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user