File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
System.CommandLine/Parsing Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -488,6 +488,38 @@ public void Custom_parser_can_check_another_option_result_for_custom_errors(stri
488
488
. Be ( "one two" ) ;
489
489
}
490
490
491
+ [ Fact ]
492
+ public void Validation_reports_all_parse_errors ( )
493
+ {
494
+ CliOption < string > firstOptionWithError = new ( "--first-option-with-error" ) ;
495
+ firstOptionWithError . Validators . Add ( optionResult => optionResult . AddError ( "first error" ) ) ;
496
+ CliOption < string > secondOptionWithError = new ( "--second-option-with-error" )
497
+ {
498
+ CustomParser = r =>
499
+ {
500
+ r . AddError ( "second error" ) ;
501
+ return r . Tokens [ 0 ] . Value ;
502
+ }
503
+ } ;
504
+
505
+ CliCommand command = new ( "cmd" )
506
+ {
507
+ firstOptionWithError ,
508
+ secondOptionWithError
509
+ } ;
510
+
511
+ ParseResult parseResult = command . Parse ( "cmd --first-option-with-error value1 --second-option-with-error value2" ) ;
512
+
513
+ OptionResult firstOptionResult = parseResult . GetResult ( firstOptionWithError ) ;
514
+ firstOptionResult . Errors . Single ( ) . Message . Should ( ) . Be ( "first error" ) ;
515
+
516
+ OptionResult secondOptionResult = parseResult . GetResult ( secondOptionWithError ) ;
517
+ secondOptionResult . Errors . Single ( ) . Message . Should ( ) . Be ( "second error" ) ;
518
+
519
+ parseResult . Errors . Should ( ) . Contain ( error => error . SymbolResult == firstOptionResult ) ;
520
+ parseResult . Errors . Should ( ) . Contain ( error => error . SymbolResult == secondOptionResult ) ;
521
+ }
522
+
491
523
[ Fact ]
492
524
public void When_custom_conversion_fails_then_an_option_does_not_accept_further_arguments ( )
493
525
{
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ private void ValidateOptions(bool completeValidation)
140
140
141
141
if ( errorsBefore != SymbolResultTree . ErrorCount )
142
142
{
143
- break ;
143
+ continue ;
144
144
}
145
145
}
146
146
You can’t perform that action at this time.
0 commit comments