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

If the option type is Nullable<T>, return CommandOptionType.SingleOrNoValue if T is CommandOptionType.SingleValue #394

Closed
2 tasks
scott-xu opened this issue Sep 13, 2020 · 5 comments
Labels
closed-stale This issue is closed because it went stale and there was no action planned. It can be reopened. enhancement help wanted We would be willing to take a well-written PR to help fix this. stale

Comments

@scott-xu
Copy link
Contributor

Is your feature request related to a problem? Please describe.
If the option type is Nullable<SomeEnum>, I have to specify CommandOptionType.SingleOrNoValue. Otherwise, the help text would be

  -enumOpt3|--verb3 <VERB3>         nullable enum option desc.
                                    Allowed values are: None, Normal, Extreme.

rather than

  -enumOpt3|--verb3[:<VERB3>]       nullable enum option desc.
                                    Allowed values are: None, Normal, Extreme.

Describe the solution you'd like

  • return CommandOptionType.SingleOrNoValue if T is CommandOptionType.SingleValue
  • improve the parser to support --a value for SingleOrNoValue to keep backwards compatibility
@natemcmaster natemcmaster added the help wanted We would be willing to take a well-written PR to help fix this. label Sep 13, 2020
@natemcmaster
Copy link
Owner

Thanks for writing this up. As long as we can preserve backwards compat, I'm okay accepting a PR to implement these features.

@scott-xu
Copy link
Contributor Author

scott-xu commented Oct 3, 2020

spec about SingleOrNoValue:

Single or no value - a special case of "no value" options where an value may or may not be specified. They can be specified as --name (no value) or --name:value or --name=value. Unlike "single value", these cannot be specified as --name value because the space causes ambiguous usage.

need to find out the exact ambiguous usage and see if we can work out a solution

@natemcmaster
Copy link
Owner

natemcmaster commented Nov 11, 2020

ambiguous usage

var app  = new CommandLIneApplication();

var optFoo = app.Option("--foo[:name]", CommandOptionType.SingleOrNoValue);
var argBar = app.Argument("bar");

app.OnExecute(() => {
   var foo = optFoo.Value() ?? "none";
   var bar = argBar.Value ?? "none";

   Console.WriteLine($"foo={foo}, bar={bar}");
});

app.Execute("--foo", "HELLO")

What does the user expect here ^ ? Should it print foo=HELLO, bar=none or foo=none, bar=HELLO?

@github-actions
Copy link

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please comment if you believe this should remain open, otherwise it will be closed in 14 days. Thank you for your contributions to this project.

@github-actions github-actions bot added the stale label Nov 13, 2021
@github-actions
Copy link

Closing due to inactivity.
If you are looking at this issue in the future and think it should be reopened, please make a commented here and mention natemcmaster so he sees the notification.

@github-actions github-actions bot added the closed-stale This issue is closed because it went stale and there was no action planned. It can be reopened. label Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-stale This issue is closed because it went stale and there was no action planned. It can be reopened. enhancement help wanted We would be willing to take a well-written PR to help fix this. stale
Projects
None yet
Development

No branches or pull requests

2 participants