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

Parsing bool options #258

Closed
JohnTube opened this issue Nov 3, 2015 · 3 comments
Closed

Parsing bool options #258

JohnTube opened this issue Nov 3, 2015 · 3 comments

Comments

@JohnTube
Copy link

JohnTube commented Nov 3, 2015

Is there a way to parse bool values instead of using all bool options as flags. What if the default value is true and I want to disable/deactivate it by toggle it to false?

@mInternauta
Copy link

Man, maybe you can use a Interger property with Min and Max, just like:

[Option("MySwitch", Max =1,Min = 0)]
public int MySwitch { get; set; }

@mInternauta
Copy link

Or better:

[Option("MySwitch", Max =1,Min = 0, Default = 1, Required = false)]
public int MySwitch { get; set; }

Can input between 0 and 1, the default value is 1 (ON) , and isnt required by the parser.

Or with boolean:

[Option("MySwitch", Default = true, Required = false)]
public bool MySwitch { get; set; }

if you went to be required, just change Required to True.

@gsscoder
Copy link
Owner

Please refer to #133 to avoid duplicated issues.

In short, actually boolean options are false when omitted and true when specified. Internally these are treated as a special case (Switch): this is done to follow the standard Unix implementation of command line syntax (normally referred as getopt standard in wiki and other issues).

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

No branches or pull requests

3 participants