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

Default value for non-existing argument #55

Closed
YauhenPyl opened this issue Jan 17, 2018 · 3 comments
Closed

Default value for non-existing argument #55

YauhenPyl opened this issue Jan 17, 2018 · 3 comments
Labels

Comments

@YauhenPyl
Copy link

Hello, thank you for the great library.

Is it possible to set different default values for ValueArgument if it is passed but without any value and if it is not passed at all? E.g.

internal class Arguments
{
    [ValueArgument(typeof(string), 'a', "argument", ValueOptional = true, DefaultValueNonExisting = "", DefaultValue = null, Optional = true)]
    public string Value { get; set; }
}
  • Value will be 'Argument':
 my-tool.exe -a Argument
  • Value will be "":
my-tool.exe
  • Value will be 'null':
my-tool.exe -a

Thanks

@j-maly
Copy link
Owner

j-maly commented Jan 17, 2018

Hi, it could be added but I can't give you any ETA atm. If you don't want to implement it yourself...

As a workaround, you could

  • not specify DefaultValue
  • after parsing the commandline, check the Parsed property of your argument and correct the value based on that

@eapyl
Copy link
Contributor

eapyl commented Jan 19, 2018

Added quick implementation for this idea.

@alexandre-lecoq
Copy link
Contributor

This was implemented. Issue can be closed.

@StefH StefH closed this as completed Jul 19, 2019
@StefH StefH added the bug label Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants