List of usage examples for org.apache.commons.cli HelpFormatter getLeftPadding
public int getLeftPadding()
From source file:com.zimbra.cs.account.ldap.upgrade.LdapUpgrade.java
static void usage(ParseException e, UpgradeOp upgradeOp, String errMsg) { if (e != null) { printer.println("Error parsing command line arguments: " + e.getMessage()); }/*from ww w . j a va 2 s. co m*/ if (errMsg != null) { printer.println(errMsg); printer.println(); } Options opts = getAllOptions(); PrintWriter pw = printer.getPrintWriter(); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(pw, formatter.getWidth(), getCommandUsage(), null, opts, formatter.getLeftPadding(), formatter.getDescPadding(), null); pw.flush(); if (upgradeOp != null) { upgradeOp.usage(formatter); } }
From source file:io.github.azige.mages.Cli.java
static void printHelp(PrintStream out, Options options) { HelpFormatter hf = new HelpFormatter(); PrintWriter pw = new PrintWriter(out); hf.printHelp(pw, hf.getWidth(),//from ww w.ja v a2 s .com "mages [-r <bundle> [-l <locale>]] [-t <template>] [-p <plugin dir>] <input files>", "Convert input files.", options, hf.getLeftPadding(), hf.getDescPadding(), null); pw.flush(); }
From source file:io.github.azige.whitespace.Cli.java
static void printHelp(PrintStream out, Options options) { HelpFormatter hf = new HelpFormatter(); PrintWriter pw = new PrintWriter(out); hf.printHelp(pw, hf.getWidth(), "whitespace [-c|-p] <source file>", "Whitespace??", options, hf.getLeftPadding(), hf.getDescPadding(), null);// ww w . java2 s. c om pw.flush(); }
From source file:com.zimbra.common.localconfig.LocalConfigUpgrade.java
static void usage(String error) { if (error != null) System.out.println("Error: " + error); Options opts = getAllOptions();//w w w .j av a2 s.c om PrintWriter pw = new PrintWriter(System.out, true); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(pw, formatter.getWidth(), getCommandUsage(), null, opts, formatter.getLeftPadding(), formatter.getDescPadding(), null); pw.flush(); if (error != null) { System.exit(1); } else { System.exit(0); } }
From source file:com.notifier.desktop.Main.java
private static void printHelp(Options options) { HelpFormatter formatter = new HelpFormatter(); String cmdSyntax = "android-notifier-desktop"; if (OperatingSystems.CURRENT_FAMILY == OperatingSystems.Family.WINDOWS) { StringWriter s = new StringWriter(); formatter.printHelp(new PrintWriter(s), 150, cmdSyntax, null, options, formatter.getLeftPadding(), formatter.getDescPadding(), null, true); showMessage(s.toString());//from ww w . j ava2s. c o m } else { formatter.printHelp(cmdSyntax, options, true); } }
From source file:com.zimbra.cs.redolog.util.PlaybackUtil.java
private static void usage(String errmsg) { if (errmsg != null) { System.err.println(errmsg); }/* w ww . j a v a 2 s . c o m*/ String usage = "zmplayredo <options>"; Options opts = sOptions; PrintWriter pw = new PrintWriter(System.err, true); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(pw, formatter.getWidth(), usage, null, opts, formatter.getLeftPadding(), formatter.getDescPadding(), null); pw.flush(); String trailer = SoapCLI.getAllowedDatetimeFormatsHelp(); if (trailer != null && trailer.length() > 0) { System.err.println(); System.err.println(trailer); } }
From source file:cz.pecina.bin.bitwriter.Parameters.java
/** * Prints usage information.//from www . jav a 2 s . com * * @param stream print stream for the output */ public static void usage(final PrintStream stream) { log.fine("Printing usage information"); final HelpFormatter helpFormatter = new HelpFormatter(); PrintWriter printWriter = new PrintWriter(stream); helpFormatter.printHelp(printWriter, helpFormatter.getWidth(), "bitwriter [options] [--] [input-file]...", null, options, helpFormatter.getLeftPadding(), helpFormatter.getDescPadding(), "(C) 2015 Tom Pecina <tomas@pecina.cz>, license: GNU/GPL"); printWriter.close(); }
From source file:ai.grakn.migration.base.MigrationCLI.java
private static void printHelpMessage(MigrationOptions options) { HelpFormatter helpFormatter = new HelpFormatter(); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(System.out, Charset.defaultCharset()); PrintWriter printWriter = new PrintWriter(new BufferedWriter(outputStreamWriter)); int width = helpFormatter.getWidth(); int leftPadding = helpFormatter.getLeftPadding(); int descPadding = helpFormatter.getDescPadding(); helpFormatter.printHelp(printWriter, width, "migration.sh", null, options.getOptions(), leftPadding, descPadding, null);//from ww w . j av a 2s .com printWriter.flush(); }
From source file:com.zimbra.qa.unittest.prov.ldap.TestLdapReadTimeout.java
private static void usage(Options options) { System.out.println("\n"); PrintWriter pw = new PrintWriter(System.out, true); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(pw, formatter.getWidth(), "zmjava " + TestLdapReadTimeout.class.getCanonicalName() + " [options]", null, options, formatter.getLeftPadding(), formatter.getDescPadding(), null); System.out.println("\n"); pw.flush();/*from w w w . j a v a 2 s .c om*/ }
From source file:io.mindmaps.graql.GraqlShell.java
public static void runShell(String[] args, String version, GraqlClient client) { Options options = new Options(); options.addOption("n", "name", true, "name of the graph"); options.addOption("e", "execute", true, "query to execute"); options.addOption("f", "file", true, "graql file path to execute"); options.addOption("u", "uri", true, "uri to connect to engine"); options.addOption("h", "help", false, "print usage message"); options.addOption("v", "version", false, "print version"); CommandLineParser parser = new DefaultParser(); CommandLine cmd;//from w w w . j a va 2 s . co m try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println(e.getMessage()); return; } String query = cmd.getOptionValue("e"); String filePath = cmd.getOptionValue("f"); // Print usage message if requested or if invalid arguments provided if (cmd.hasOption("h") || !cmd.getArgList().isEmpty()) { HelpFormatter helpFormatter = new HelpFormatter(); PrintWriter printWriter = new PrintWriter(System.out); int width = helpFormatter.getWidth(); int leftPadding = helpFormatter.getLeftPadding(); int descPadding = helpFormatter.getDescPadding(); helpFormatter.printHelp(printWriter, width, "graql.sh", null, options, leftPadding, descPadding, null); printWriter.flush(); return; } if (cmd.hasOption("v")) { System.out.println(version); return; } String namespace = cmd.getOptionValue("n", DEFAULT_NAMESPACE); String uriString = cmd.getOptionValue("u", DEFAULT_URI); try (GraqlShell shell = new GraqlShell(namespace)) { client.connect(shell, new URI("ws://" + uriString + REMOTE_SHELL_URI)); if (filePath != null) { query = loadQuery(filePath); } if (query != null) { shell.executeQuery(query); shell.commit(); } else { shell.executeRepl(); } } catch (IOException | InterruptedException | ExecutionException | URISyntaxException e) { System.err.println(e.toString()); } finally { client.close(); } }