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 33
44using System . Collections . Generic ;
55using System . CommandLine . Parsing ;
6+ using System . CommandLine . Tests . Utility ;
67using System . IO ;
78using FluentAssertions ;
89using System . Linq ;
@@ -692,6 +693,28 @@ public void OnlyTake_throws_when_called_twice()
692693 . Should ( )
693694 . Be ( "OnlyTake can only be called once." ) ;
694695 }
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+ }
695718 }
696719
697720 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)
6464 throw new InvalidOperationException ( $ "{ nameof ( OnlyTake ) } can only be called once.") ;
6565 }
6666
67- if ( numberOfTokens == 0 )
68- {
69- return ;
70- }
71-
7267 var passedOnTokensCount = _tokens . Count - numberOfTokens ;
7368
7469 PassedOnTokens = new List < Token > ( _tokens . GetRange ( numberOfTokens , passedOnTokensCount ) ) ;
You can’t perform that action at this time.
0 commit comments