dotnet / dotnet/command-line-api
Make multiple arity option overflow behavior consistent with argument behavior
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
This currently works:
```csharp
var intsArg = new Argument();
var stringsArg = new Argument();
var root = new RootCommand
{
intsArg,
stringsArg
};
var result = root.Parse("1 2 3 four five");
var _ = new AssertionScope();
result.ValueForArgument(intsArg)
.Should()
.BeEquivalentTo(new[] { 1, 2, 3 },
options => options.WithStrictOrdering());
result.ValueForArgument(stringsArg)
.Should()
.Be("four");
result.UnparsedTokens.Should()
.ContainSingle()
.Which
.Should()
.Be("five");
```
This (with the change of `intArg` to `intsOption`) does not:
```csharp
var intsOption = new Option("-i");
var stringsArg = new Argument("arg");
var root = new RootCommand
{
intsOption,
stringsArg
};
var result = root.Parse("-i 1 2 3 four");
result.FindResultFor(intsOption)
.GetValueOrDefault()
.Should()
.BeEquivalentTo(new[] { 1, 2, 3 }, options => options.WithStrictOrdering());
result.FindResultFor(stringsArg)
.Should()
.Be("four");
```
It seems these should be consistent, although the fact that arguments are positional and options are not might make this unintuitive.
Contributor guide
Assessment
This issue has not been assessed yet.