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

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

Introduction

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

Prototype

int DEFAULT_LEFT_PAD

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

Click Source Link

Document

default padding to the left of each line

Usage

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

@SuppressWarnings("static-access")
public static CommandLine parse(String[] otherArgs, Writer out) {
    Options options = new Options();
    options.addOption(OptionBuilder/* w  w  w  . jav  a 2  s  .c  om*/
            .withDescription("Disables the blockcache for this table. (Enabled by default)").create("b"));

    options.addOption(OptionBuilder
            .withDescription("Disables the table when it is created. (Enabled by default)").create("d"));

    options.addOption(OptionBuilder.withDescription("Enabled strict types on a table. (Disabled by default)")
            .create("s"));

    options.addOption(
            OptionBuilder.withDescription("Enables a read only table. (Disabled by default)").create("r"));

    options.addOption(OptionBuilder.isRequired().hasArg().withArgName("tablename")
            .withDescription("* The table name.").create("t"));

    options.addOption(OptionBuilder.isRequired().hasArg().withArgName("shard count")
            .withDescription("* The number of shards in the table.").create("c"));

    options.addOption(OptionBuilder.hasArg().withArgName("uri")
            .withDescription("The location of the table. (Example hdfs://namenode/blur/tables/table)")
            .create("l"));

    options.addOption(OptionBuilder.withArgName("filetype").hasOptionalArgs().withDescription(
            "Sets the filetypes (.tim, .tis, .doc, etc.) to be cached in the block cache. (All by default)")
            .create("B"));

    options.addOption(OptionBuilder.withDescription(
            "If table is not strict, disables the missing field, fieldless indexing. (Enabled by default)")
            .create("mfi"));

    options.addOption(OptionBuilder.withArgName("field type").hasArg()
            .withDescription(
                    "If table is not strict, sets the field type for the missing field. (text by default)")
            .create("mft"));

    options.addOption(OptionBuilder.withArgName("name value").hasArgs(2)
            .withDescription("If table is not strict, sets the properties for the missing field.")
            .create("mfp"));

    options.addOption(OptionBuilder.withArgName("name value").hasArgs(2)
            .withDescription("Sets the properties for this table descriptor.").create("p"));

    options.addOption(OptionBuilder.withArgName("column name*").hasArgs()
            .withDescription(
                    "Sets what columns to pre cache during warmup. (By default all columns are cached)")
            .create("P"));

    options.addOption(OptionBuilder.withArgName("classname").hasArg().withDescription(
            "Sets the similarity class for the table. (By org.apache.blur.lucene.search.FairSimilarity is used)")
            .create("S"));

    options.addOption(OptionBuilder.withDescription("Displays help for this command.").create("h"));

    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, "create", 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, "create", null, options,
                HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
        return null;
    }
    return cmd;
}

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

@SuppressWarnings("static-access")
public CommandLine parse(String[] otherArgs, Writer out) {
    Options options = new Options();
    options.addOption(OptionBuilder.withDescription("The path to write temp files.").hasArg().isRequired(true)
            .create("p"));
    options.addOption(OptionBuilder.withDescription("The size of the temp files (1 GB by default).").hasArg()
            .create("s"));
    options.addOption(OptionBuilder.withDescription("Number of cycles of the test. (10 by default)").hasArg()
            .create("S"));
    options.addOption(//from   w  ww .  ja v a 2s .  c  om
            OptionBuilder.withDescription("Number of warmup cycles. (3 by default)").hasArg().create("W"));
    options.addOption(OptionBuilder.withDescription("Min buffer size power of 2 (12 by default 4KB)").hasArg()
            .create("n"));
    options.addOption(OptionBuilder.withDescription("Max buffer size power of 2 (19 by default 512KB)").hasArg()
            .create("x"));
    options.addOption(
            OptionBuilder.withDescription("Number of random read samples during read test. (1000 by default)")
                    .hasArg().create("r"));
    options.addOption(OptionBuilder.withDescription("Displays help for this command.").create("h"));

    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, name(), 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, name(), null, options,
                HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
        return null;
    }
    return cmd;
}

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  w w . ja v  a 2  s  .  c o  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  w w .j  a  v  a 2 s  . c  om
    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  w  w w  .j  a  v  a2s  . c om*/
    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();/* w w w. j  a v a  2 s  . co 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();/* w w  w  .  j a va 2 s.  co m*/
}

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

public void displayHelp(PrintStream stdout) {
    stdout.println();// w  ww  . j  a  v  a  2s . co 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);//w  w w  .  j a  v  a 2s .  co m
}

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  .  jav  a2  s  . c o  m
}