List of usage examples for org.apache.commons.cli HelpFormatter printUsage
public void printUsage(PrintWriter pw, int width, String cmdLineSyntax)
From source file:io.werval.cli.DamnSmallDevShell.java
private static void printHelp(Options options, PrintWriter out) { HelpFormatter help = new HelpFormatter(); help.setOptionComparator(new OptionsComparator()); help.printUsage(out, WIDTH, "io.werval.cli [options] [command(s)]"); out.print("\n" + " The Damn Small Werval DevShell\n" + " - do not manage dependencies ;\n" + " - do not allow you to extend the build ;\n" + " - do not assemble applications.\n"); help.printWrapped(out, WIDTH, 2,/* w w w .ja va2 s . c o m*/ "\n" + "Meaning you have to manage your application dependencies and assembly yourself. " + "Theses limitations make this DevShell suitable for quick prototyping only. " + "Prefer the Gradle or Maven build systems integration."); out.println("\n io.werval.cli is part of the Werval Development Kit - http://werval.io"); out.println("\n" + "Commands:\n\n" + " new <appdir> Create a new skeleton application in the 'appdir' directory.\n" + " secret Generate a new application secret.\n" + " clean Delete devshell temporary directory, see 'tmpdir' option.\n" + " devshell Run the Application in development mode.\n" + " start Run the Application in production mode.\n" + "\n" + " If no command is specified, 'start' is assumed."); out.println("\n" + "Options:" + "\n"); help.printOptions(out, WIDTH, options, 2, 2); help.printWrapped(out, WIDTH, 2, "\n" + "All paths are relative to the current working directory, " + "except if they are absolute of course."); help.printWrapped(out, WIDTH, 2, "\n" + "Licensed under the Apache License Version 2.0, http://www.apache.org/licenses/LICENSE-2.0"); out.println(); }
From source file:com.aleerant.tnssync.PropertiesHandler.java
private void printUsageInfo() { final String header = "\n" + APP_NAME + " creates " + APP_TNSNAMES_FILENAME + " file for services listed in a config file (" + APP_TNSSYNC_FILENAME + ") getting Oracle Net Description data from a directory server (described in " + APP_LDAPORA_FILENAME + ").\n\n"; final String footer = "\n" + "Licensed under the Apache License Version 2.0, http://www.apache.org/licenses/LICENSE-2.0"; final String warning_msg = "WARNING: " + APP_NAME + " is able to owerwrite the existing " + APP_TNSNAMES_FILENAME + " file!\n\n"; final String logging_msg = APP_NAME + " provides logging functionality using Simple Logging Facade for Java (SLF4J) with a logback backend. " + "Logback looks for a configuration file named " + APP_TNSSYNC_LOGBACK_FILENAME + " in TNS_ADMIN directory.\n\n"; final int width = 120; final PrintWriter writer = new PrintWriter(System.out); HelpFormatter formatter = new HelpFormatter(); formatter.printUsage(writer, width, "java -jar " + APP_NAME + ".jar [-ta <DIR>]"); formatter.printUsage(writer, width, "java -jar " + APP_NAME + ".jar -h"); formatter.printUsage(writer, width, "java -jar " + APP_NAME + ".jar -v"); formatter.printWrapped(writer, width, header); formatter.printWrapped(writer, width, warning_msg); formatter.printWrapped(writer, width, logging_msg); formatter.printOptions(writer, width, mOptions, 1, 3); formatter.printWrapped(writer, width, footer); writer.close();/*from w ww. j a v a2s.c o m*/ }
From source file:openlr.otk.options.UsageBuilder.java
/** * Prints the command line syntax.//www . j a v a 2 s .c o m * * @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:org.apache.parquet.tools.Main.java
public static void showUsage(HelpFormatter format, PrintWriter err, String name, Command command) { Options options = mergeOptions(OPTIONS, command.getOptions()); String[] usage = command.getUsageDescription(); String ustr = name + " [option...]"; if (usage != null && usage.length >= 1) { ustr = ustr + " " + usage[0]; }/*from w w w . j ava 2s.c o m*/ format.printWrapped(err, WIDTH, name + ":\n" + command.getCommandDescription()); format.printUsage(err, WIDTH, ustr); format.printWrapped(err, WIDTH, LEFT_PAD, "where option is one of:"); format.printOptions(err, WIDTH, options, LEFT_PAD, DESC_PAD); if (usage != null && usage.length >= 2) { for (int i = 1; i < usage.length; ++i) { format.printWrapped(err, WIDTH, LEFT_PAD, usage[i]); } } }
From source file:org.esxx.Main.java
private static void usage(Options opt, String error, int rc) { PrintWriter err = new PrintWriter(System.err); HelpFormatter hf = new HelpFormatter(); hf.printUsage(err, 80, "esxx.jar [OPTION...] [--script -- <script.js> SCRIPT ARGS...]"); hf.printOptions(err, 80, opt, 2, 8); if (error != null) { err.println();//from w w w .j av a 2 s. c o m hf.printWrapped(err, 80, "Invalid arguments: " + error + "."); } err.flush(); System.exit(rc); }
From source file:parquet.tools.Main.java
public static void showUsage(HelpFormatter format, PrintWriter err, String name, Command command) { Options options = mergeOptions(OPTIONS, command.getOptions()); String[] usage = command.getUsageDescription(); String ustr = name + " [option...]"; if (usage != null && usage.length >= 1) { ustr = ustr + " " + usage[0]; }//w ww . j av a 2 s. com format.printUsage(err, WIDTH, ustr); format.printWrapped(err, WIDTH, LEFT_PAD, "where option is one of:"); format.printOptions(err, WIDTH, options, LEFT_PAD, DESC_PAD); if (usage != null && usage.length >= 2) { for (int i = 1; i < usage.length; ++i) { format.printWrapped(err, WIDTH, LEFT_PAD, usage[i]); } } }