@Test public void testMissingRequiredOptions() throws CLIException { String[] args = new String[]{"-a"}; TypedOption<String> b = new TypedOption<String>().setShortName("b").setLongName("bfile").setSingleValued(true) .setDescription("set the value of [b]").setType(String.class).setRequired(true); TypedOption<Boolean> c = new TypedOption<Boolean>().setShortName("c").setLongName("copt").setSingleValued(false) .setDescription("turn [c] on or off").setType(Boolean.class).setRequired(true); cli.removeOption("b").addOption(b).removeOption("c").addOption(c); try { CommandLine evaluated = cli.parse(Arrays.asList(args)); fail("exception expected"); } catch (MissingOptionException e) { assertThat(e.getExpected()).hasSize(2); } }
/** * Removes an option identified by its name. This method does nothing if the option cannot be found. * @param name the option name * @return the current {@link io.vertx.rxjava.core.cli.CLI} instance */ public io.vertx.rxjava.core.cli.CLI removeOption(String name) { delegate.removeOption(name); return this; }
/** * Removes an option identified by its name. This method does nothing if the option cannot be found. * @param name the option name * @return the current {@link io.vertx.rxjava.core.cli.CLI} instance */ public io.vertx.rxjava.core.cli.CLI removeOption(String name) { delegate.removeOption(name); return this; }
@Test public void testMissingRequiredOptions() throws CLIException { String[] args = new String[]{"-a"}; TypedOption<String> b = new TypedOption<String>().setShortName("b").setLongName("bfile").setSingleValued(true) .setDescription("set the value of [b]").setType(String.class).setRequired(true); TypedOption<Boolean> c = new TypedOption<Boolean>().setShortName("c").setLongName("copt").setSingleValued(false) .setDescription("turn [c] on or off").setType(Boolean.class).setRequired(true); cli.removeOption("b").addOption(b).removeOption("c").addOption(c); try { CommandLine evaluated = cli.parse(Arrays.asList(args)); fail("exception expected"); } catch (MissingOptionException e) { assertThat(e.getExpected()).hasSize(2); } }