commandline
commandline copied to clipboard
bool value is not support
code:
static void Main(string[] args)
{
args = new[] {
"--y-up-to-z-up", "false",
"E:\\0.obj",
"E:\\DeskTop\\output1",
};
var result=Parser.Default.ParseArguments<Options>(args);
result.Value.Dump();
}
public class Options
{
[Value(0, MetaName = "Input", Required = true, HelpText = "Input OBJ file.")]
public string Input { get; set; }
[Value(1, MetaName = "Output", Required = true, HelpText = "Output folder.")]
public string Output { get; set; }
[Option('t',"y-up-to-z-up", Required = false, HelpText = "Convert the upward Y-axis ",Default=true)]
public bool YUpToZUp { get; set; }
}
YUpToZUp is not right,and input will be override by YUpToZUp's value
if YUpToZUp is bool? type,it will be right;
[Option('t',"y-up-to-z-up", Required = false, HelpText = "Convert the upward Y-axis ",Default=true)]
-- public bool YUpToZUp { get; set; }
++ public bool? YUpToZUp { get; set; }
bool parameters are a Switch Option. If the option is passed to the command line, it will always be true.
For your desired behavior (being able to pass it and set it to false) you need to declare it as a bool?.
For documentation about this, see:
https://github.com/commandlineparser/commandline/wiki/CommandLine-Grammar#switch-option
boolparameters are aSwitch Option. If the option is passed to the command line, it will always betrue.For your desired behavior (being able to pass it and set it to
false) you need to declare it as abool?.For documentation about this, see:
https://github.com/commandlineparser/commandline/wiki/CommandLine-Grammar#switch-option
Thanks