Skip to content

Commit

Permalink
[#1125] added test for option param matching subcmd name
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Jul 12, 2020
1 parent debaf5f commit 6042bd8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/java/picocli/UnmatchedOptionTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package picocli;

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.ProvideSystemProperty;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.rules.TestRule;
import picocli.CommandLine.Command;
import picocli.CommandLine.MissingParameterException;
import picocli.CommandLine.Option;
import picocli.CommandLine.OverwrittenOptionException;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.ParseResult;
import picocli.CommandLine.UnmatchedArgumentException;

import java.util.Arrays;
Expand Down Expand Up @@ -580,4 +583,21 @@ class App {
assertEquals("-2", app.x);
assertEquals(Arrays.asList("-3", "-0", "-0.0", "-NaN"), app.y);
}

@Ignore("#1125")
@Test // https://github.com/remkop/picocli/issues/1125
public void testSubcommandAsOptionValue() {
@Command(name = "app")
class App {
@Option(names = "-x") String x;

@Command
public int search() {
return 123;
}
}
ParseResult parseResult = new CommandLine(new App()).parseArgs("-x", "search", "search");
assertEquals("search", parseResult.matchedOptionValue("-x", null));
assertTrue(parseResult.hasSubcommand());
}
}

0 comments on commit 6042bd8

Please sign in to comment.