-
Notifications
You must be signed in to change notification settings - Fork 755
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
Command line utils: allow 'inherited' options #131
Conversation
@@ -52,14 +65,18 @@ public CommandLineApplication(bool throwOnUnexpectedArg = true) | |||
return command; | |||
} | |||
|
|||
public CommandOption Option(string template, string description, CommandOptionType optionType) | |||
public CommandOption Option(string template, string description, CommandOptionType optionType, bool inherited = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change (API/binary compatibility). Consider adding an overload
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Will do.
🆙 📅 |
Ping for review. (FYI I originally listed bricelam for sign off, but he's out on paternity leave now) |
return Option(template, description, optionType, _ => { }); | ||
} | ||
=> Option(template, description, optionType, _ => { }, inherited: false); | ||
public CommandOption Option(string template, string description, CommandOptionType optionType, bool inherited) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: add a newline above this method.
@moozzyk can you finish reviewing and sign off? |
|
||
[Fact] | ||
public void NestedOptionConflictThrows() | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you have nested options with the same name if they are not inherited (i.e. --ask would overwrite --always)? Can you add a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when options are not inherited (default), only the subcommand-local options are searched. I'll add a sanity test for it.
🚢🇮🇹 |
50e1a92
to
1380d8d
Compare
Some options apply to all subcommands. This makes improves usability so that inherited commands can be specified in any order