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

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

Introduction

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

Prototype

@GenIgnore
CLI usage(StringBuilder builder);

Source Link

Document

Generates the usage / help of the current CLI .

Usage

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);
}

From source file:examples.cli.CLIExamples.java

License:Open Source License

public void example9(PrintStream stream) {
    CLI cli = CLI.create("test")
            .addOption(new Option().setLongName("help").setShortName("h").setFlag(true).setHelp(true))
            .addOption(new Option().setLongName("mandatory").setRequired(true));

    CommandLine line = cli.parse(Collections.singletonList("-h"));

    // The parsing does not fail and let you do:
    if (!line.isValid() && line.isAskingForHelp()) {
        StringBuilder builder = new StringBuilder();
        cli.usage(builder);
        stream.print(builder.toString());
    }//from w w  w .  ja  v a 2s  .c o  m
}