-
Notifications
You must be signed in to change notification settings - Fork 373
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
[main] Issue with this pattern: inner -x one -x two
#2388
Comments
I don't remember POSIX itself specifying any subcommands, or how options should be parsed with subcommands. My hunch is that, in But perhaps "Posix rules" refers to historic System.CommandLine behaviour with which you want to preserve compatibility. |
There are two things at play here. First is the arity of the option. In this case it is zero or one because it is With So in that test above, to make it work as you expect you would do this: [Fact]
public void Options_only_apply_to_the_nearest_command()
{
var outerOption = new CliOption<string>("-x");
var innerOption = new CliOption<string>("-x") { AllowMultipleArgumentsPerToken = true };
var outer = new CliCommand("outer")
{
new CliCommand("inner")
{
innerOption
},
outerOption
};
var result = outer.Parse("outer inner -x one -x two");
result.Errors.Should().BeNullOrEmpty();
result.GetValue<string>(innerOption).Should().Be("two");
result.RootCommandResult
.GetResult(outerOption)
.Should()
.BeNull();
} Now there is an argument to be made that the default of |
But there are no multiple argument tokens per option token in |
My understanding of Posix rules for
is that it should result in "two" for "-x" when the declaration is what is included in this test:
I added the two commented out lines, and with either enabled, the test fails.
This is one of a handful of tests that are failing as I work on Powderhouse, and the behavior of System.CommandLine in these cases is not what I expected.
The biggest thing I need right now is whether this scenario should pass with the two commented out lines enabled.
@jonsequitur @Keboo
The text was updated successfully, but these errors were encountered: