Skip to content

Commit

Permalink
Respond to PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate McMaster committed Jun 29, 2016
1 parent 9dc976b commit 50e1a92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public CommandLineApplication Command(string name, Action<CommandLineApplication

public CommandOption Option(string template, string description, CommandOptionType optionType)
=> Option(template, description, optionType, _ => { }, inherited: false);

public CommandOption Option(string template, string description, CommandOptionType optionType, bool inherited)
=> Option(template, description, optionType, _ => { }, inherited);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,29 @@ public void NestedOptionConflictThrows()
Assert.Throws<InvalidOperationException>(() => app.Execute("subcmd", "-a", "b"));
}

[Fact]
public void OptionsWithSameName()
{
var app = new CommandLineApplication();
var top = app.Option("-a|--always", "Top-level", CommandOptionType.SingleValue, inherited: false);
CommandOption nested = null;
app.Command("subcmd", c =>
{
nested = c.Option("-a|--ask", "Nested", CommandOptionType.SingleValue);
});

app.Execute("-a", "top");
Assert.Equal("top", top.Value());
Assert.Null(nested.Value());

top.Values.Clear();

app.Execute("subcmd", "-a", "nested");
Assert.Null(top.Value());
Assert.Equal("nested", nested.Value());
}


[Fact]
public void NestedInheritedOptions()
{
Expand Down

0 comments on commit 50e1a92

Please sign in to comment.