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:
Jarryd Beck 2018-03-08 08:53:26 +11:00
parent 76bd60dc17
commit e40645e084
2 changed files with 2 additions and 1 deletions

View File

@ -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 + ")");
}

View File

@ -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>()