List of usage examples for org.apache.commons.cli HelpFormatter DEFAULT_WIDTH
int DEFAULT_WIDTH
To view the source code for org.apache.commons.cli HelpFormatter DEFAULT_WIDTH.
Click Source Link
From source file:eu.scape_project.tool.toolwrapper.component_uploader.ComponentUploader.java
/** * Method used to print command-line syntax (usage) using * {@link HelpFormatter}//from w w w . j a va2 s . c o m */ private void printUsage() { HelpFormatter helpFormatter = new HelpFormatter(); PrintWriter systemErrPrintWriter = new PrintWriter( new OutputStreamWriter(System.err, Charset.defaultCharset()), true); helpFormatter.printHelp(systemErrPrintWriter, HelpFormatter.DEFAULT_WIDTH, "\"" + getClass().getSimpleName() + ".jar\"", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, Constants.SCAPE_COPYRIGHT_STATEMENT, true); }
From source file:com.google.caja.plugin.Config.java
public void usage(String msg, PrintWriter out) { out.println(BuildInfo.getInstance().getBuildInfo()); out.println();/*from w w w . j av a2 s . c o m*/ if (msg != null && !"".equals(msg)) { out.println(msg); out.println(); } new HelpFormatter().printHelp(out, HelpFormatter.DEFAULT_WIDTH, (mainClass.getSimpleName() + " --input <in.html> [--output_js <out.js> | --out <out>]"), "\n", options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, "\n" + usageText, false); out.println(); int maxPlanStateWidth = 0; for (Pair<String, String> doc : PipelineMaker.getPreconditionDocumentation()) { maxPlanStateWidth = Math.max(maxPlanStateWidth, doc.a.length()); } for (Pair<String, String> doc : PipelineMaker.getGoalDocumentation()) { maxPlanStateWidth = Math.max(maxPlanStateWidth, doc.a.length()); } String fmtStr = "%" + maxPlanStateWidth + "s | %s"; out.println("Preconditions (default to " + PipelineMaker.DEFAULT_PRECONDS + ")"); for (Pair<String, String> doc : PipelineMaker.getPreconditionDocumentation()) { out.println(String.format(fmtStr, doc.a, doc.b)); } out.println(); out.println("Goals (default to " + PipelineMaker.DEFAULT_GOALS + ")"); for (Pair<String, String> doc : PipelineMaker.getGoalDocumentation()) { out.println(String.format(fmtStr, doc.a, doc.b)); } }
From source file:com.marklogic.contentpump.Command.java
public void printUsage(Command cmd, Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(HelpFormatter.DEFAULT_WIDTH, cmd.name(), null, options, null, true); }
From source file:nl.strohalm.cyclos.setup.Arguments.java
static void printHelp(final Options options) { final HelpFormatter formatter = new HelpFormatter(); formatter.defaultSyntaxPrefix = ""; formatter.defaultLongOptPrefix = " --"; final PrintWriter printWriter = new PrintWriter(Setup.getOut()); formatter.printHelp(printWriter, HelpFormatter.DEFAULT_WIDTH, Setup.getResourceBundle().getString("help.header") + ":\n", "", options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, "", false); printWriter.flush();// w w w . jav a 2 s . c o m System.exit(1); }
From source file:openlr.otk.options.UsageBuilder.java
/** * Prints the command line syntax./* w w w . ja va2 s .c om*/ * * @param target * The target stream to write to * @param options * The tool options * @param argsList * The tool arguments * @param toolID * The tool short name * @param toolDescription * The description of the tool */ public static void usage(final OutputStream target, final Options options, final List<Argument<?>> argsList, final String toolID, final String toolDescription) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(new OutputStreamWriter(target, IOUtils.SYSTEM_DEFAULT_CHARSET)); String optionsListStr = buildOptionsList(options); String argsListStr = buildArgumentsList(argsList); formatter.printUsage(pw, HelpFormatter.DEFAULT_WIDTH, "java -jar otk-<version>.jar " + toolID + " " + optionsListStr + " " + argsListStr); formatter.printWrapped(pw, HelpFormatter.DEFAULT_WIDTH, toolDescription); if (options.getOptions().size() > 0) { formatter.printOptions(pw, HelpFormatter.DEFAULT_WIDTH, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD); } printArgumentDescriptions(pw, argsList); formatter.printWrapped(pw, HelpFormatter.DEFAULT_WIDTH, USAGE_FOOTER); pw.flush(); }
From source file:openlr.otk.options.UsageBuilder.java
/** * Prints the help for the tool arguments. * /*from ww w .jav a 2 s . c o m*/ * @param pw * The writer to use * @param args * The tool arguments */ private static void printArgumentDescriptions(final PrintWriter pw, final List<Argument<?>> args) { if (args.size() > 0) { pw.write(IOUtils.LINE_SEPARATOR); // We use the HelpFormatter to format the argument help for us // by providing fake options containing the arguments Options options = new Options(); for (Argument<?> argument : args) { Option opt = new Option(null, argument.getName(), false, argument.getDescription()); options.addOption(opt); } HelpFormatter formatter = new HelpFormatter(); formatter.setLongOptPrefix(""); formatter.printOptions(pw, HelpFormatter.DEFAULT_WIDTH, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD); } }
From source file:org.apache.blur.shell.AddColumnDefinitionCommand.java
@SuppressWarnings("static-access") private static CommandLine parse(String[] otherArgs, Writer out) { Options options = new Options(); options.addOption(OptionBuilder.withArgName("sub column name").hasArg() .withDescription("The sub column name of the new column definition.").create("s")); options.addOption(OptionBuilder/* w ww.java2 s .com*/ .withDescription( "Should the column definition be definied as a field less indexing column definition.") .create("F")); options.addOption(OptionBuilder.withArgName("name value").hasArgs(2) .withDescription("Sets the properties for this column definition.").create("p")); options.addOption(OptionBuilder .withDescription("Should the column definition be definied as a sortable column definition.") .create("S")); options.addOption(OptionBuilder .withDescription("Should the column definition be definied as a multi value column definition.") .create("M")); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; 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, "definecolumn", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } return cmd; }
From source file:org.apache.blur.shell.CopyTableCommand.java
@SuppressWarnings("static-access") public static CommandLine parse(String[] otherArgs, Writer out) { Options options = new Options(); options.addOption(OptionBuilder.isRequired().hasArg().withArgName("tablename") .withDescription("* Source table name.").create("src")); options.addOption(OptionBuilder.isRequired().hasArg().withArgName("tablename") .withDescription("* Target table name.").create("dest")); options.addOption(OptionBuilder.isRequired().hasArg().withArgName("cluster") .withDescription("* Target cluster for new table.").create("c")); options.addOption(OptionBuilder.hasArg().isRequired().withArgName("uri") .withDescription("The location of the target table. (Example hdfs://namenode/blur/tables/table)") .create("l")); options.addOption(OptionBuilder.withDescription("Displays help for this command.").create("h")); CommandLineParser parser = new PosixParser(); CommandLine cmd = null;//from w w w. ja v a 2s . co m 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, "copy", 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, "copy", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } return cmd; }
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//from w ww . j a v a2 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.j a v a 2 s . co m 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; }