Example usage for io.vertx.core.cli CommandLine isAskingForHelp

List of usage examples for io.vertx.core.cli CommandLine isAskingForHelp

Introduction

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

Prototype

boolean isAskingForHelp();

Source Link

Document

Checks whether or not the user has passed a "help" option and is asking for help.

Usage

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);/*from www .ja  v a  2 s  .  c  o  m*/
        stream.print(builder.toString());
    }
}