Search in sources :

Example 6 with BuiltinHelpFormatter

use of joptsimple.BuiltinHelpFormatter in project universa by UniversaBlockchain.

the class CLIMain method usage.

private static void usage(String text) {
    boolean error = false;
    PrintStream out = System.out;
    if (text != null) {
        out = System.err;
        error = true;
    }
    out.println("\nUniversa client tool, v. " + CLI_VERSION + "\n");
    if (options == null)
        System.err.println("error while parsing command line");
    else {
        Integer columns = (Integer) options.valueOf("term-width");
        if (columns == null)
            columns = 120;
        if (text != null)
            out.println("ERROR: " + text + "\n");
        try {
            parser.formatHelpWith(new BuiltinHelpFormatter(columns, 2));
            parser.printHelpOn(out);
            out.println("\nOnline docs: https://lnd.im/UniClientUserManual\n");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    System.exit(100);
}
Also used : BuiltinHelpFormatter(joptsimple.BuiltinHelpFormatter)

Example 7 with BuiltinHelpFormatter

use of joptsimple.BuiltinHelpFormatter in project spring-boot by spring-projects.

the class OptionHandler method getHelp.

public String getHelp() {
    if (this.help == null) {
        getParser().formatHelpWith(new BuiltinHelpFormatter(80, 2));
        OutputStream out = new ByteArrayOutputStream();
        try {
            getParser().printHelpOn(out);
        } catch (IOException ex) {
            return "Help not available";
        }
        this.help = out.toString().replace(" --cp ", " -cp  ");
    }
    return this.help;
}
Also used : BuiltinHelpFormatter(joptsimple.BuiltinHelpFormatter) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 8 with BuiltinHelpFormatter

use of joptsimple.BuiltinHelpFormatter in project hazelcast-simulator by hazelcast.

the class CliUtils method printHelpAndExit.

static void printHelpAndExit(OptionParser parser, OutputStream sink) {
    try {
        parser.formatHelpWith(new BuiltinHelpFormatter(HELP_WIDTH, HELP_INDENTATION));
        parser.printHelpOn(sink);
    } catch (Exception e) {
        throw new CommandLineExitException("Could not print command line help", e);
    }
    exit(0);
}
Also used : BuiltinHelpFormatter(joptsimple.BuiltinHelpFormatter) OptionException(joptsimple.OptionException)

Aggregations

BuiltinHelpFormatter (joptsimple.BuiltinHelpFormatter)8 OptionException (joptsimple.OptionException)5 OptionParser (joptsimple.OptionParser)4 OptionSet (joptsimple.OptionSet)4 IOException (java.io.IOException)2 Terminal (org.jline.terminal.Terminal)2 Injector (com.google.inject.Injector)1 Config (com.typesafe.config.Config)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Field (java.lang.reflect.Field)1 Socket (java.net.Socket)1 Path (java.nio.file.Path)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 LanternClassLoader (org.lanternpowered.launch.LanternClassLoader)1 LanternModule (org.lanternpowered.server.inject.LanternModule)1 FinalFieldClassTransformer (org.lanternpowered.server.transformer.FinalFieldClassTransformer)1