Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bool value is not support #916

Open
dashenxian opened this issue Feb 22, 2024 · 3 comments
Open

bool value is not support #916

dashenxian opened this issue Feb 22, 2024 · 3 comments

Comments

@dashenxian
Copy link

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
image

@dashenxian
Copy link
Author

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; }

image

@je-sendra
Copy link

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

@dashenxian
Copy link
Author

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

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants