use of io.vertx.core.cli.CLI in project vert.x by eclipse.
the class CLIExamples method example6.
public void example6() {
CLI cli = CLI.create("copy").setSummary("A command line interface to copy files.").addOption(new Option().setLongName("directory").setShortName("R").setDescription("enables directory support").setFlag(true)).addArgument(new Argument().setIndex(0).setDescription("The source").setArgName("source")).addArgument(new Argument().setIndex(0).setDescription("The destination").setArgName("target"));
StringBuilder builder = new StringBuilder();
cli.usage(builder);
}
use of io.vertx.core.cli.CLI in project vert.x by eclipse.
the class TypedCLIExamples method example4.
public void example4(List<String> userCommandLineArguments) {
CLI cli = CLI.create(AnnotatedCli.class);
CommandLine commandLine = cli.parse(userCommandLineArguments);
AnnotatedCli instance = new AnnotatedCli();
CLIConfigurator.inject(commandLine, instance);
}
use of io.vertx.core.cli.CLI in project vert.x by eclipse.
the class ServiceCommandLookupTest method ensureCommand.
private void ensureCommand(Collection<CommandFactory<?>> commands, String name) {
List<CLI> clis = new ArrayList<>();
for (CommandFactory command : commands) {
CLI cli = command.define();
clis.add(cli);
if (cli.getName().equalsIgnoreCase(name)) {
return;
}
}
fail("Cannot find '" + name + "' in " + clis.stream().map(CLI::getName).collect(Collectors.toList()));
}
use of io.vertx.core.cli.CLI in project vert.x by eclipse.
the class ServiceCommandLoaderTest method ensureCommand.
private void ensureCommand(Collection<CommandFactory<?>> commands, String name) {
List<CLI> clis = new ArrayList<>();
for (CommandFactory command : commands) {
CLI cli = command.define();
clis.add(cli);
if (cli.getName().equalsIgnoreCase(name)) {
return;
}
}
fail("Cannot find '" + name + "' in " + clis.stream().map(CLI::getName).collect(Collectors.toList()));
}
use of io.vertx.core.cli.CLI in project vert.x by eclipse.
the class DefaultCommandTest method testCWD.
@Test
public void testCWD() throws CLIException {
CLI cli = CLIConfigurator.define(command.getClass());
CommandLine evaluatedCLI = parse(cli, "--name=vert.x");
CLIConfigurator.inject(evaluatedCLI, command);
assertThat(command.getCwd()).isEqualTo(new File("."));
evaluatedCLI = parse(cli, "--cwd=target", "--name=vert.x");
CLIConfigurator.inject(evaluatedCLI, command);
assertThat(command.getCwd()).isEqualTo(new File("target"));
}
Aggregations