mirror of https://github.com/jarro2783/cxxopts.git
Don't show default when boolean false
Fixes #102. Don't show the default value when it is a boolean and the value is false. Note that this is a bit of a hack and the implementation should probably be reevaluated in the future.
This commit is contained in:
parent
76bd60dc17
commit
e40645e084
|
|
@ -1372,7 +1372,7 @@ namespace cxxopts
|
|||
{
|
||||
auto desc = o.desc;
|
||||
|
||||
if (o.has_default)
|
||||
if (o.has_default && (!o.is_boolean || o.default_value != "false"))
|
||||
{
|
||||
desc += toLocalString(" (default: " + o.default_value + ")");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ int main(int argc, char* argv[])
|
|||
options.add_options()
|
||||
("a,apple", "an apple", cxxopts::value<bool>(apple))
|
||||
("b,bob", "Bob")
|
||||
("t,true", "True", cxxopts::value<bool>()->default_value("true"))
|
||||
("f, file", "File", cxxopts::value<std::vector<std::string>>(), "FILE")
|
||||
("i,input", "Input", cxxopts::value<std::string>())
|
||||
("o,output", "Output file", cxxopts::value<std::string>()
|
||||
|
|
|
|||
Loading…
Reference in New Issue