Search in sources :

Example 6 with Argument

use of io.vertx.core.cli.Argument in project vert.x by eclipse.

the class DefaultParserTest method testThatOnlyOneArgumentCanBeMultivalued.

@Test(expected = CLIException.class)
public void testThatOnlyOneArgumentCanBeMultivalued() {
    CLI cli = new DefaultCLI().setName("test");
    cli.addArgument(new Argument().setIndex(0));
    cli.addArgument(new Argument().setIndex(1).setMultiValued(true));
    cli.addArgument(new Argument().setIndex(2).setMultiValued(true));
    cli.parse(Arrays.asList("a", "b", "c", "d"));
}
Also used : Argument(io.vertx.core.cli.Argument) Test(org.junit.Test)

Example 7 with Argument

use of io.vertx.core.cli.Argument in project vert.x by eclipse.

the class DefaultParserTest method testThatArgumentIndexCanBeGeneratedWithPartiallyNumberedArguments.

@Test
public void testThatArgumentIndexCanBeGeneratedWithPartiallyNumberedArguments() {
    CLI cli = new DefaultCLI().setName("test");
    cli.addArgument(new Argument());
    cli.addArgument(new Argument().setIndex(1));
    cli.addArgument(new Argument().setMultiValued(true));
    CommandLine line = cli.parse(Arrays.asList("a", "b", "c", "d"));
    assertThat((String) line.getArgumentValue(0)).isEqualToIgnoringCase("a");
    assertThat((String) line.getArgumentValue(1)).isEqualToIgnoringCase("b");
    assertThat(line.getArgumentValues(2)).containsExactly("c", "d");
}
Also used : Argument(io.vertx.core.cli.Argument) Test(org.junit.Test)

Aggregations

Argument (io.vertx.core.cli.Argument)7 Test (org.junit.Test)6 CLI (io.vertx.core.cli.CLI)1 Option (io.vertx.core.cli.Option)1