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

Command line utils: allow 'inherited' options #131

Merged
merged 1 commit into from
Jun 29, 2016
Merged

Conversation

natemcmaster
Copy link

@natemcmaster natemcmaster commented Jun 22, 2016

Some options apply to all subcommands. This makes improves usability so that inherited commands can be specified in any order

@@ -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)
Copy link

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

Copy link
Author

Choose a reason for hiding this comment

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

Gotcha. Will do.

@natemcmaster
Copy link
Author

🆙 📅

@natemcmaster
Copy link
Author

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)
Copy link
Member

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.

@Eilon
Copy link
Member

Eilon commented Jun 28, 2016

@moozzyk can you finish reviewing and sign off?


[Fact]
public void NestedOptionConflictThrows()
{
Copy link

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?

Copy link
Author

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.

@moozzyk
Copy link

moozzyk commented Jun 28, 2016

🚢🇮🇹

@natemcmaster natemcmaster merged commit 1380d8d into dev Jun 29, 2016
@natemcmaster natemcmaster deleted the namc/inherited branch July 1, 2016 13:26
@ghost ghost locked as resolved and limited conversation to collaborators May 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants