-
Notifications
You must be signed in to change notification settings - Fork 415
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Reproduce
#:package System.CommandLine@2.0.0
using System;
using System.CommandLine;
using System.CommandLine.Parsing;
using System.Linq;
Func<ArgumentResult, string[]> takeTwo = r => {
r.OnlyTake(2);
return r.Tokens.Select(t => t.Value).ToArray();
};
RootCommand root = new() {
new Argument<string[]>("arg1") { Arity = new(1, 15), CustomParser = takeTwo },
new Argument<string[]>("arg2") { Arity = new(1, 3), CustomParser = takeTwo },
new Argument<string[]>("arg3") { Arity = new(1, 3), CustomParser = takeTwo },
new Argument<string[]>("arg4") { Arity = new(1, 3), CustomParser = takeTwo },
new Argument<string[]>("arg5") { Arity = new(1, 3), CustomParser = takeTwo },
new Argument<string[]>("arg6") { Arity = new(1, 10) },
};
var result = root.Parse(Enumerable.Range(1, 20).Select(i => i.ToString()).ToArray());
foreach(Argument<string[]> a in root.Arguments) {
Console.WriteLine($"{a.Name}: {string.Join(", ", result.GetRequiredValue(a))}");
}Expected output
arg1: 1, 2
arg2: 3, 4
arg3: 5, 6
arg4: 7, 8
arg5: 9, 10
arg6: 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
Actual output
arg1: 1, 2
arg2: 16, 17
arg3: 19, 20
arg4: 4, 5
arg5: 7, 8
arg6: 10, 11, 12, 13, 14, 15, 18, 3, 6, 9
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working