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

Show allowed values in help text for Nullable/ValueTuple<bool,T> option/argument #390

Conversation

scott-xu
Copy link
Contributor

@scott-xu scott-xu commented Aug 30, 2020

Fix #388

@scott-xu scott-xu changed the title fix https://github.com/natemcmaster/CommandLineUtils/issues/388 Show allowed values in help text for Nullable/ValueTuple<bool,T> option/argument Aug 30, 2020
@scott-xu scott-xu marked this pull request as ready for review August 30, 2020 11:10
@scott-xu
Copy link
Contributor Author

@natemcmaster
If the option type is Nullable<T>, should we return CommandOptionType.SingleOrNoValue if T is CommandOptionType.SingleValue
https://github.com/natemcmaster/CommandLineUtils/blob/main/src/CommandLineUtils/Internal/CommandOptionTypeMapper.cs#L63

@scott-xu
Copy link
Contributor Author

@natemcmaster
If the option type is Nullable<T>, should we return CommandOptionType.SingleOrNoValue if T is CommandOptionType.SingleValue
https://github.com/natemcmaster/CommandLineUtils/blob/main/src/CommandLineUtils/Internal/CommandOptionTypeMapper.cs#L63

I ask because 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.

[Option(CommandOptionType.SingleOrNoValue, ShortName = "enumOpt3", Description = "nullable enum option desc.")]
public SomeEnum? Verb3 { get; set; }

Copy link
Owner

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! There is a merge conflict now, though, with your other PR. Can you resolved and update?

@natemcmaster
Copy link
Owner

re: your question

If the option type is Nullable, should we return CommandOptionType.SingleOrNoValue if T is CommandOptionType.SingleValue

Let's open a separate issue for this. We need to think through backwards compatibility of this change given that the current behavior is SingleValue. I think changing to SingleOrNoValue could break some users unless we also improve the parser to support --a value for SingleOrNoValue.

@scott-xu
Copy link
Contributor Author

Conflicts are resolved.
Issue #394 is created.

@natemcmaster natemcmaster merged commit 0c9fe6b into natemcmaster:main Sep 13, 2020
@natemcmaster
Copy link
Owner

Thanks @scott-xu !

@scott-xu scott-xu deleted the nullable-option-allowed-values-in-help-text branch January 18, 2021 11:54
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

Successfully merging this pull request may close these issues.

[Question] Best way to implement not required Enum-based option
2 participants