Nullable boolean Options aren't supported
goncalo-oliveira opened this issue · comments
Describe the bug
When using a nullable boolean with an option of type CommandOptionType.SingleOrNoValue
, the argument value isn't binded. It only works if the property isn't nullable.
To Reproduce
Using version 4.0.2 of the library. To reproduce, add a property with a nullable boolean
public class InstallCommand
{
[Option( "--install-proxy", CommandOptionType.SingleOrNoValue )]
public bool? InstallProxy { get; set; }
protected Task<int> OnExecute( CommandLineApplication app )
{
Console.WriteLine( $"install proxy: {InstallProxy}" );
return Task.FromResult( 0 );
}
}
Execute with the argument --install-proxy
or --install-proxy=true
or --install-proxy=false
.
The InstallProperty
value will still be set to null.
The output
$ dotnet run -- install --install-proxy
install proxy:
Expected behavior
I would expect the argument value to be binded to the property value.
Screenshots
Did you try this instead?
CommandLineUtils/docs/docs/options.md
Lines 73 to 76 in 81199c7