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

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

Introduction

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

Prototype

int DEFAULT_WIDTH

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

Click Source Link

Document

default number of characters per line

Usage

From source file:org.apache.blur.shell.ExecutePlatformCommandCommand.java

private CommandLine parse(String commandName, Options options, String[] args, PrintWriter out) {
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;//w ww .  j a va 2  s .co m
    try {
        cmd = parser.parse(options, args);
        if (cmd.hasOption("h")) {
            HelpFormatter formatter = new HelpFormatter();
            PrintWriter pw = new PrintWriter(out, true);
            formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, commandName, null, options,
                    HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
            return null;
        }
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        PrintWriter pw = new PrintWriter(out, true);
        formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, commandName, null, options,
                HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
        return null;
    }
    return cmd;
}

From source file:org.apache.blur.shell.QueryCommandHelper.java

@SuppressWarnings("static-access")
public static CommandLine parse(String[] otherArgs, Writer out, String usage) {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArgs().withDescription("* Query string.").isRequired().create(QUERY));
    options.addOption(OptionBuilder.withDescription("Disables row query. (Enabled by default)")
            .create(DISABLE_ROW_QUERY));
    options.addOption(OptionBuilder.hasArg().withArgName(SCORE_TYPE)
            .withDescription("Specify the scoring type.").create(SCORE_TYPE));
    options.addOption(OptionBuilder.hasArgs().withArgName(ROW_FILTER).withDescription("Specify row filter.")
            .create(ROW_FILTER));//from   w ww . j a  v a 2  s . c o m
    options.addOption(OptionBuilder.hasArgs().withArgName(RECORD_FILTER)
            .withDescription("Specify record filter.").create(RECORD_FILTER));
    options.addOption(OptionBuilder.hasArg().withArgName(START)
            .withDescription("Specify the starting position (paging).").create(START));
    options.addOption(OptionBuilder.hasArg().withArgName(FETCH)
            .withDescription("Specify the number of elements to fetch in a single page.").create(FETCH));
    options.addOption(OptionBuilder.hasArg().withArgName(MAX_QUERY_TIME)
            .withDescription("Specify the maximum amount of time to allow query to execute.")
            .create(MAX_QUERY_TIME));
    options.addOption(OptionBuilder.hasArg().withArgName(MINIMUM_NUMBER_OF_RESULTS)
            .withDescription("Specify the minimum number of results required before returning from query.")
            .create(MINIMUM_NUMBER_OF_RESULTS));
    options.addOption(OptionBuilder.hasArg().withArgName(ROW_ID)
            .withDescription(
                    "Specify the rowId to execute the query against (this reduces the spray to other shards).")
            .create(ROW_ID));
    options.addOption(OptionBuilder.withArgName(FACET).hasArgs()
            .withDescription("Specify facet to be executed with this query.").create(FACET));
    options.addOption(OptionBuilder.withArgName(SORT).hasArgs()
            .withDescription("Specify a sort to be applied to this query <family> <column> [<reverse>].")
            .create(SORT));
    options.addOption(OptionBuilder.withDescription("Displays help for this command.").create("h"));
    options.addOption(OptionBuilder.withArgName(WIDTH).hasArgs()
            .withDescription("Specify max column width for display.").create(WIDTH));

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, otherArgs);
        if (cmd.hasOption("h")) {
            HelpFormatter formatter = new HelpFormatter();
            PrintWriter pw = new PrintWriter(out, true);
            formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, usage, null, options,
                    HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
            return null;
        }
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        PrintWriter pw = new PrintWriter(out, true);
        formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, usage, null, options,
                HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
        return null;
    }
    return cmd;
}

From source file:org.apache.blur.shell.TermsDataCommand.java

@SuppressWarnings("static-access")
private static CommandLine parse(String[] otherArgs, Writer out) {
    Options options = new Options();
    options.addOption(OptionBuilder.withArgName("startwith").hasArg()
            .withDescription("The value to start with.").create("s"));
    options.addOption(OptionBuilder.withArgName("size").hasArg()
            .withDescription("The number of terms to return.").create("n"));
    options.addOption(OptionBuilder.withDescription("Get the frequency of each term.").create("F"));

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;/*from   www .  j av a  2  s.com*/
    try {
        cmd = parser.parse(options, otherArgs);
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        PrintWriter pw = new PrintWriter(out, true);
        formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "terms", null, options,
                HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
        return null;
    }
    return cmd;
}

From source file:org.apache.hadoop.yarn.client.cli.ClusterCLI.java

@VisibleForTesting
void printUsage(Options opts) throws UnsupportedEncodingException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(baos, Charset.forName("UTF-8")));
    new HelpFormatter().printHelp(pw, HelpFormatter.DEFAULT_WIDTH, TITLE, null, opts,
            HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null);
    pw.close();//from  w  ww.  j  a va 2 s . c o  m
    sysout.println(baos.toString("UTF-8"));
}

From source file:org.apache.hcatalog.cli.HCatCli.java

private static void printUsage(Options options, OutputStream os) {
    PrintWriter pw = new PrintWriter(os);
    new HelpFormatter().printHelp(pw, 2 * HelpFormatter.DEFAULT_WIDTH,
            "hcat { -e \"<query>\" | -f \"<filepath>\" } [ -g \"<group>\" ] [ -p \"<perms>\" ] [ -D\"<name>=<value>\" ]",
            null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
    pw.flush();//  ww  w  . j  a v  a 2  s.  com
}

From source file:org.apache.hive.hcatalog.streaming.StreamingIntegrationTester.java

static void usage(Options options) {
    HelpFormatter hf = new HelpFormatter();
    hf.printHelp(HelpFormatter.DEFAULT_WIDTH, "sit [options]", "Usage: ", options, "");
    System.exit(-1);//from ww w. ja  va  2  s . c o  m
}

From source file:org.apache.maven.cli.CLIManager.java

public void displayHelp(PrintStream stdout) {
    stdout.println();//from   w w  w .j  a  v  a2  s . c  o m

    PrintWriter pw = new PrintWriter(stdout);

    HelpFormatter formatter = new HelpFormatter();

    formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:",
            options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, "\n", false);

    pw.flush();
}

From source file:org.apache.ofbiz.base.start.StartupCommandUtil.java

static final void printOfbizStartupHelp(final PrintStream printStream) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp(new PrintWriter(printStream, true), HelpFormatter.DEFAULT_WIDTH + 6,
            "ofbiz|ofbizDebug|ofbizBackground",
            System.lineSeparator() + "Executes OFBiz command e.g. start, shutdown, check status, etc",
            getOfbizStartupOptions(), HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD,
            "note: Only one command can execute at a time. Portoffset may be appended." + System.lineSeparator()
                    + "Also a command must be invoked separately for each argument e.g."
                    + System.lineSeparator()
                    + "gradlew \"ofbiz --test component=somecomp --test case=somecase\"",
            true);//from   ww w.  j  av a  2s . c  om
}

From source file:org.apereo.portal.shell.PortalShell.java

protected static void printHelp(final Options options) {
    final HelpFormatter formatter = new HelpFormatter();
    final PrintWriter pw = new PrintWriter(System.err);
    formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "java " + PortalShell.class.getName(), null, options,
            HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, true);
    pw.flush();//from ww w  .j  a va  2s .c  om
}

From source file:org.commonjava.emb.boot.main.EMBCLIManager.java

public void displayHelp(final PrintStream stdout) {
    stdout.println();/*from w w w .  j  a  v a  2 s.  c  o  m*/

    final PrintWriter pw = new PrintWriter(stdout);

    final HelpFormatter formatter = new HelpFormatter();

    formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "xvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:",
            options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, "\n", false);

    pw.flush();
}