command-line-api
command-line-api copied to clipboard
--help output lacks "[default: true]" if Option<bool> has `DefaultValueFactory` returning `true`
System.CommandLine version 2.0.0-rc.2.25502.107
Define an Option with a DefaultValueFactory for some non-default value and --help outputs the option, description and default value UNLESS the type is bool then the default is omitted even though DefaultValueFactory returns true
...
new Option<int>("--bool")
{
Description = "Bool value"
},
new Option<int>("--bool-default")
{
Description = "Bool value with default",
DefaultValueFactory = result => { return true; }
},
new Option<int>("--int")
{
Description = "Int value"
},
new Option<int>("--int-default")
{
Description = "Int value with default",
DefaultValueFactory = result => { return 123; }
},
new Option<string>("--string")
{
Description = "String value"
},
new Option<string>("--string-default")
{
Description = "String value with default",
DefaultValueFactory = result => { return "my.default.value"; }
},
...
Run foo.exe --help and the output's
...
--bool Bool value
--bool-default Bool value with default
--int <int> Int value
--int-default <int-default> Int value with default [default: 123]
--string <string> String value
--string-default <string-default> String value with default [default: my.default.value]
...
The 2nd line is wrong it should end with "[default: true]" e.g.
--bool-default Bool value with default [default: true]