File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
System.CommandLine/Parsing Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 3
3
4
4
using System . Collections . Generic ;
5
5
using System . CommandLine . Parsing ;
6
+ using System . CommandLine . Tests . Utility ;
6
7
using System . IO ;
7
8
using FluentAssertions ;
8
9
using System . Linq ;
@@ -692,6 +693,28 @@ public void OnlyTake_throws_when_called_twice()
692
693
. Should ( )
693
694
. Be ( "OnlyTake can only be called once." ) ;
694
695
}
696
+
697
+ [ Fact ]
698
+ public void OnlyTake_can_pass_on_all_tokens ( )
699
+ {
700
+ var argument1 = new Argument < int [ ] > ( result =>
701
+ {
702
+ result . OnlyTake ( 0 ) ;
703
+ return null ;
704
+ } ) ;
705
+ var argument2 = new Argument < int [ ] > ( ) ;
706
+ var command = new RootCommand
707
+ {
708
+ argument1 ,
709
+ argument2
710
+ } ;
711
+
712
+ var result = command . Parse ( "1 2 3" ) ;
713
+
714
+ result . GetValueForArgument ( argument1 ) . Should ( ) . BeEmpty ( ) ;
715
+
716
+ result . GetValueForArgument ( argument2 ) . Should ( ) . BeEquivalentSequenceTo ( 1 , 2 , 3 ) ;
717
+ }
695
718
}
696
719
697
720
protected override Symbol CreateSymbol ( string name )
Original file line number Diff line number Diff line change @@ -64,11 +64,6 @@ public void OnlyTake(int numberOfTokens)
64
64
throw new InvalidOperationException ( $ "{ nameof ( OnlyTake ) } can only be called once.") ;
65
65
}
66
66
67
- if ( numberOfTokens == 0 )
68
- {
69
- return ;
70
- }
71
-
72
67
var passedOnTokensCount = _tokens . Count - numberOfTokens ;
73
68
74
69
PassedOnTokens = new List < Token > ( _tokens . GetRange ( numberOfTokens , passedOnTokensCount ) ) ;
You can’t perform that action at this time.
0 commit comments