List of usage examples for org.apache.commons.cli HelpFormatter printWrapped
public void printWrapped(PrintWriter pw, int width, int nextLineTabStop, String text)
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, "\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,/*www. j a v a2 s. c o m*/ "\n" + "Licensed under the Apache License Version 2.0, http://www.apache.org/licenses/LICENSE-2.0"); out.println(); }
From source file:com.emc.ecs.sync.cli.CliHelper.java
public static String longHelp() { StringWriter helpWriter = new StringWriter(); PrintWriter pw = new PrintWriter(helpWriter); HelpFormatter fmt = new HelpFormatter(); fmt.setWidth(79);//from w ww . ja v a2s . co m // main CLI options Options options = ConfigUtil.wrapperFor(CliConfig.class).getOptions(); // sync options for (Option o : ConfigUtil.wrapperFor(SyncOptions.class).getOptions().getOptions()) { options.addOption(o); } // Make sure we do CommonOptions first String usage = "java -jar ecs-sync.jar -source <source-uri> [-filters <filter1>[,<filter2>,...]] -target <target-uri> [options]"; fmt.printHelp(pw, fmt.getWidth(), usage, "Common options:", options, fmt.getLeftPadding(), fmt.getDescPadding(), null); pw.print("\nAvailable plugins are listed below along with any custom options they may have\n"); // Do the rest for (ConfigWrapper<?> storageWrapper : ConfigUtil.allStorageConfigWrappers()) { pw.write('\n'); pw.write(String.format("%s (%s)\n", storageWrapper.getLabel(), storageWrapper.getUriPrefix())); fmt.printWrapped(pw, fmt.getWidth(), 4, " " + storageWrapper.getDocumentation()); fmt.printWrapped(pw, fmt.getWidth(), 4, " NOTE: Storage options must be prefixed by source- or target-, depending on which role they assume"); fmt.printOptions(pw, fmt.getWidth(), storageWrapper.getOptions(), fmt.getLeftPadding(), fmt.getDescPadding()); } for (ConfigWrapper<?> filterWrapper : ConfigUtil.allFilterConfigWrappers()) { pw.write('\n'); pw.write(String.format("%s (%s)\n", filterWrapper.getLabel(), filterWrapper.getCliName())); fmt.printWrapped(pw, fmt.getWidth(), 4, " " + filterWrapper.getDocumentation()); fmt.printOptions(pw, fmt.getWidth(), filterWrapper.getOptions(), fmt.getLeftPadding(), fmt.getDescPadding()); } return helpWriter.toString(); }
From source file:name.livitski.databag.cli.Syntax.java
protected void listOptions(Collection<Option> options, PrintWriter out) { HelpFormatter formatter = getHelpFormatter(); for (Option option : options) { out.printf(" %s%s%n", formatOptionHeader(option), formatArguments(option)); String summary = "## NO DESCRIPTION PROVIDED ##"; try {/* w w w . j av a2 s. co m*/ String id = getOptionId(option); summary = getResources().getString(USAGE_BUNDLE, getClass(), id); } catch (MissingResourceException missing) { } out.print(" "); formatter.printWrapped(out, OUTPUT_WIDTH - 8, 8, summary); } if (!options.isEmpty()) out.println(); }
From source file:org.fusesource.hawtjni.generator.HawtJNI.java
private void pw(String message, int indent) { PrintWriter out = new PrintWriter(System.out); HelpFormatter formatter = new HelpFormatter(); formatter.printWrapped(out, 78, indent, message); out.flush();/* w ww . j a v a 2 s .c o m*/ }
From source file:org.springframework.migrationanalyzer.commandline.AbstractMigrationAnalysis.java
private void displayUsage() { PrintWriter writer = new PrintWriter(System.out); HelpFormatter helpFormatter = new HelpFormatter(); writer.println(String.format("Usage: migration-analysis.%s <inputPath> [OPTION]...", getScriptSuffix())); printHeader("Description:", writer); helpFormatter.printWrapped(writer, OPTIONS_WIDTH, OPTIONS_INDENT, DESCRIPTION); printHeader("Options:", writer); helpFormatter.printOptions(writer, OPTIONS_WIDTH, OPTIONS, OPTIONS_INDENT, OPTIONS_INDENT); writer.flush();/*from w w w. j a v a 2 s. c om*/ }
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 . c o m 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]); } } }