Skip to content

Command line utils: allow 'inherited' options - #131

Merged
natemcmaster merged 1 commit into
devfrom
namc/inherited
Jun 29, 2016
Merged

natemcmaster merged 1 commit into
devfrom
namc/inherited

Conversation

@natemcmaster

@natemcmaster natemcmaster commented Jun 22, 2016 •

Copy link
Copy Markdown

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

}

public CommandOption Option(string template, string description, CommandOptionType optionType)
public CommandOption Option(string template, string description, CommandOptionType optionType, bool inherited = false)

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Author

🆙 📅

@natemcmaster

Copy link
Copy Markdown
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
Copy Markdown

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

Eilon commented Jun 28, 2016

Copy link
Copy Markdown

@moozzyk can you finish reviewing and sign off?


[Fact]
public void NestedOptionConflictThrows()
{

Copy link
Copy Markdown

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
Copy Markdown
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

moozzyk commented Jun 28, 2016

Copy link
Copy Markdown

🚢🇮🇹

@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