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

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

Introduction

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

Prototype

boolean isValid();

Source Link

Document

Checks whether or not the command line is valid, i.e.

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   w ww .ja v a2 s.c  o m
        stream.print(builder.toString());
    }
}