File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1414import picocli .CommandLine .Option ;
1515import picocli .CommandLine .ParameterException ;
1616import picocli .CommandLine .Parameters ;
17+ import picocli .CommandLine .ParseResult ;
1718
1819import java .util .*;
1920
@@ -504,4 +505,24 @@ public void testIssue1159WithEquals() {
504505 assertEquals (345 , bean .x );
505506 }
506507
508+ @ Test
509+ public void testIssue1159ParseResult () {
510+ Issue1159 bean = new Issue1159 ();
511+ CommandLine cmd = new CommandLine (bean ).setAbbreviatedOptionsAllowed (true );
512+ ParseResult parseResult = cmd .parseArgs ("sub" , "--x" , "345" );
513+ assertEquals (345 , bean .x );
514+
515+ assertTrue (parseResult .hasSubcommand ());
516+ ParseResult subResult = parseResult .subcommand ();
517+
518+ assertTrue ("Matched on the subcommand" , subResult .hasMatchedOption ("--xxx-yyy" ));
519+ Object subValue = subResult .matchedOption ("--xxx-yyy" ).getValue ();
520+ assertEquals (345 , subValue );
521+
522+ assertFalse ("Abbreviated options not supported in ParseResult..." ,
523+ subResult .hasMatchedOption ("--x" )); // this does not work
524+
525+ assertFalse ("Not matched on the parent command" ,
526+ parseResult .hasMatchedOption ("--xxx-yyy" ));
527+ }
507528}
You can’t perform that action at this time.
0 commit comments