Example usage for io.vertx.core.cli Argument Argument

List of usage examples for io.vertx.core.cli Argument Argument

Introduction

In this page you can find the example usage for io.vertx.core.cli Argument Argument.

Prototype

public Argument() 

Source Link

Document

Creates a new empty instance of Argument .

Usage

From source file:examples.cli.CLIExamples.java

License:Open Source License

public void example1() {
    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(1).setDescription("The destination").setArgName("target"));
}

From source file:examples.cli.CLIExamples.java

License:Open Source License

public void example5() {
    CLI cli = CLI.create("some-name")
            .addArgument(new Argument().setIndex(0).setDescription("the first argument").setArgName("arg1"))
            .addArgument(new Argument().setIndex(1).setDescription("the second argument").setArgName("arg2"));
}

From source file:examples.cli.CLIExamples.java

License:Open Source License

public void example51() {
    CLI cli = CLI.create("some-name")
            // will have the index 0
            .addArgument(new Argument().setDescription("the first argument").setArgName("arg1"))
            // will have the index 1
            .addArgument(new Argument().setDescription("the second argument").setArgName("arg2"));
}

From source file:examples.cli.CLIExamples.java

License:Open Source License

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);//  w  w  w.j  a va  2s. c  om
}

From source file:examples.ShellExamples.java

License:Open Source License

public void cliCommand() {
    CLI cli = CLI.create("my-command").addArgument(new Argument().setArgName("my-arg"))
            .addOption(new Option().setShortName("m").setLongName("my-option"));
    CommandBuilder command = CommandBuilder.command(cli);
    command.processHandler(process -> {

        CommandLine commandLine = process.commandLine();

        String argValue = commandLine.getArgumentValue(0);
        String optValue = commandLine.getOptionValue("my-option");
        process.write("The argument is " + argValue + " and the option is " + optValue);

        process.end();/*  w  w w .  j a  v  a2 s. com*/
    });
}

From source file:examples.ShellExamples.java

License:Open Source License

public void cliCommandWithHelp() {
    CLI cli = CLI.create("my-command").addArgument(new Argument().setArgName("my-arg"))
            .addOption(new Option().setArgName("help").setShortName("h").setLongName("help"));
    CommandBuilder command = CommandBuilder.command(cli);
    command.processHandler(process -> {
        // .../*from  ww  w.j a  va 2s.  c om*/
    });
}