List of usage examples for org.apache.commons.cli HelpFormatter DEFAULT_LEFT_PAD
int DEFAULT_LEFT_PAD
To view the source code for org.apache.commons.cli HelpFormatter DEFAULT_LEFT_PAD.
Click Source Link
From source file:hivemall.UDTFWithOptions.java
@Nonnull protected final CommandLine parseOptions(String optionValue) throws UDFArgumentException { String[] args = optionValue.split("\\s+"); Options opts = getOptions();//from ww w .j a v a 2 s .c o m 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); }/*from w w w .j ava 2 s. c o m*/ 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); }//from w w w . j ava 2s.com 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 .j a va 2 s . co 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/*ww w .j a v a 2 s . co 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 ww w .j av a 2 s . c o m*/ * @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 . j av a2 s.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 www. j a v a 2 s. c o m*/ }
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(); }