Example usage for org.apache.commons.cli HelpFormatter DEFAULT_DESC_PAD

List of usage examples for org.apache.commons.cli HelpFormatter DEFAULT_DESC_PAD

Introduction

In this page you can find the example usage for org.apache.commons.cli HelpFormatter DEFAULT_DESC_PAD.

Prototype

int DEFAULT_DESC_PAD

To view the source code for org.apache.commons.cli HelpFormatter DEFAULT_DESC_PAD.

Click Source Link

Document

the number of characters of padding to be prefixed to each description line

Usage

From source file:hivemall.UDTFWithOptions.java

@Nonnull
protected final CommandLine parseOptions(String optionValue) throws UDFArgumentException {
    String[] args = optionValue.split("\\s+");
    Options opts = getOptions();//from   w  w  w .ja  v a2s .  com
    opts.addOption("help", false, "Show function help");
    CommandLine cl = CommandLineUtils.parseOptions(args, opts);

    if (cl.hasOption("help")) {
        Description funcDesc = getClass().getAnnotation(Description.class);
        final String cmdLineSyntax;
        if (funcDesc == null) {
            cmdLineSyntax = getClass().getSimpleName();
        } else {
            String funcName = funcDesc.name();
            cmdLineSyntax = funcName == null ? getClass().getSimpleName()
                    : funcDesc.value().replace("_FUNC_", funcDesc.name());
        }
        StringWriter sw = new StringWriter();
        sw.write('\n');
        PrintWriter pw = new PrintWriter(sw);
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, cmdLineSyntax, null, opts,
                HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, true);
        pw.flush();
        String helpMsg = sw.toString();
        throw new UDFArgumentException(helpMsg);
    }

    return cl;
}

From source file:de.static_interface.sinkscripts.scriptengine.scriptcommand.ScriptCommandBase.java

public HelpFormatter getCliHelpFormatter(Writer writer) {
    if (cliHelpFormatter == null) {
        cliHelpFormatter = new HelpFormatter();
        cliHelpFormatter.setNewLine(System.lineSeparator());
        cliHelpFormatter.printHelp(new PrintWriter(writer), HelpFormatter.DEFAULT_WIDTH,
                getSyntax().replaceAll("\\{COMMAND\\}", getName()), null, options,
                HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null);
    }/* w w  w  .ja  v a  2 s.c  om*/
    return cliHelpFormatter;
}

From source file:de.static_interface.sinklibrary.api.command.SinkCommandOptions.java

public HelpFormatter getCliHelpFormatter(Writer writer) {
    if (cliHelpFormatter == null) {
        cliHelpFormatter = new HelpFormatter();
        cliHelpFormatter.setNewLine(System.lineSeparator());
        cliHelpFormatter.printHelp(new PrintWriter(writer), HelpFormatter.DEFAULT_WIDTH,
                getCmdLineSyntax().replaceAll("\\{ALIAS\\}", parentCommand.getCmdAlias())
                        .replaceAll("\\{PREFIX\\}", parentCommand.getCommandPrefix()),
                null, getCliOptions(), HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null);
    }//ww  w.jav  a2 s  . co m
    return cliHelpFormatter;
}

From source file:com.archivas.clienttools.arcmover.cli.AbstractArcCli.java

public String helpScreen() {
    StringBuffer usage = new StringBuffer();
    HelpFormatter formatter = new HelpFormatter();

    if (cliOrder != null && cliOrder.size() > 0) {
        formatter.setOptionComparator(new OptionComparator());
    }//from  w  w  w . ja  v a2  s. c o  m

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    formatter.printHelp(pw, HCPMoverProperties.CLI_WIDTH.getAsInt(), getHelpUsageLine(), null /* header */,
            getOptions(), HelpFormatter.DEFAULT_LEFT_PAD /* leftPad */,
            HelpFormatter.DEFAULT_DESC_PAD /* descPad */, null /* footer */, false /* autoUsage */
    );

    usage.append(getHelpHeader());
    usage.append(sw.toString());
    usage.append(getHelpFooter());
    return usage.toString();
}

From source file:com.ottogroup.bi.streaming.runtime.StreamingAppRuntime.java

/**
 * Prints the usage instruction/* w w w.jav a2s  .c o  m*/
 * @param outputStream
 */
protected void printUsage(final OutputStream outputStream) throws IOException {
    if (outputStream == null)
        throw new IOException("Missing required output stream\n");
    HelpFormatter formatter = new HelpFormatter();
    PrintWriter pw = new PrintWriter(outputStream);
    formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "streaming-app", "", getOptions(),
            HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, "");
    pw.flush();
}

From source file:com.cloudera.cli.validator.components.CommandLineOptions.java

/**
 * Writes usage message to outputstream.
 *
 * @param appName the application name.//from w ww . jav a 2 s  .com
 * @param stream output stream.
 * @throws UnsupportedEncodingException
 */
public static void printUsageMessage(String appName, OutputStream stream) throws UnsupportedEncodingException {
    PrintWriter writer = new PrintWriter(
            new BufferedWriter(new OutputStreamWriter(stream, Constants.CHARSET_UTF_8)));
    try {
        String header = "Validates Cloudera Manager Schemas";
        String footer = "";
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(writer, HelpFormatter.DEFAULT_WIDTH, appName, header, OPTIONS,
                HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, footer, true); // auto-usage: whether to also show
                                                                                                                                                                                  // the command line args on the usage line.
    } finally {
        writer.close();
    }
}

From source file:glacierpipe.GlacierPipeMain.java

public static void printHelp(PrintWriter writer) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp(writer, HelpFormatter.DEFAULT_WIDTH,
            "<other-command> ... | java -jar glacierpipe.jar [--help | --upload] -e <glacier-endpoint> -v <vault-nane> <archive-name>",
            null, OPTIONS, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null);

    writer.printf("%nBuild-in endpoint aliases:%n%n");
    for (Entry<String, String> entry : ConfigBuilder.GLACIER_ENDPOINTS.entrySet()) {
        writer.printf("  %20s %s%n", entry.getKey() + " ->", entry.getValue());
    }/*from w w  w  .ja v  a2s . c o m*/

    writer.flush();
}

From source file:io.github.alechenninger.monarch.CliInputs.java

public String helpMessage() {
    StringWriter result = new StringWriter();
    PrintWriter printWriter = new PrintWriter(result);

    helpFormatter.printHelp(printWriter, 80,
            "monarch --hierarchy hierarchy.yaml --changes changes.yaml --target teams/myteam.yaml "
                    + "--data-dir ~/hieradata --output-dir ./",
            null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD,
            "https://github.com/alechenninger/monarch");

    return result.toString();
}

From source file:net.sf.clirr.cli.Clirr.java

private void printUsage(Options options, OutputStream os) {
    HelpFormatter hf = new HelpFormatter();
    PrintWriter out = new PrintWriter(os);
    hf.printHelp(out, 75, "java " + getClass().getName() + " -o path -n path [options]", null, options,
            HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null);
    out.flush();//from   w w  w  .j  a va 2 s. c  om
}

From source file:de.weltraumschaf.jebnf.cli.CliOptions.java

/**
 * Format the command line options./*from w  w w. j av  a2 s. c o  m*/
 *
 * Useful to show help message.
 *
 * @param formatter Formatter to format with.
 * @param out Stream to print formatted output.
 */
public void format(final HelpFormatter formatter, final PrintStream out) {
    final PrintWriter writer = new PrintWriter(out);
    formatter.printHelp(writer, HelpFormatter.DEFAULT_WIDTH, EXECUTABLE, HEADER, options,
            HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, FOOTER, true);
    writer.flush();
}