List of usage examples for org.apache.commons.cli2.util HelpFormatter setPrintWriter
public void setPrintWriter(PrintWriter out)
From source file:com.gsinnovations.howdah.CommandLineUtil.java
/** * Print the options supported by <code>GenericOptionsParser</code>. * In addition to the options supported by the job, passed in as the * group parameter./*w w w . j a v a 2s. c o m*/ * * @param group job-specific command-line options. */ public static void printHelpWithGenericOptions(Group group) { org.apache.commons.cli.Options ops = new org.apache.commons.cli.Options(); new GenericOptionsParser(new Configuration(), ops, new String[0]); org.apache.commons.cli.HelpFormatter fmt = new org.apache.commons.cli.HelpFormatter(); fmt.printHelp("<command> [Generic Options] [Job-Specific Options]", "Generic Options:", ops, ""); PrintWriter pw = new PrintWriter(System.out); HelpFormatter formatter = new HelpFormatter(); formatter.setGroup(group); formatter.setPrintWriter(pw); formatter.printHelp(); pw.flush(); }
From source file:it.jnrpe.server.console.PluginCommand.java
public String getCommandLine() { ByteArrayOutputStream bout = new ByteArrayOutputStream(); Group g = getCommandLineGroup(); HelpFormatter hf = new HelpFormatter(null, null, null, getConsole().getTerminal().getWidth()); hf.setGroup(g);/* w w w. jav a 2 s. com*/ hf.setPrintWriter(new PrintWriter(new OutputStreamWriter(bout, charset))); hf.printUsage(); String usage = new String(bout.toByteArray(), charset); String[] lines = usage.split("\\n"); StringBuilder res = new StringBuilder(); for (int i = 1; i < lines.length; i++) { res.append(lines[i]); } return res.toString(); }
From source file:it.jnrpe.server.console.PluginCommand.java
public void printHelp() throws IOException { Group g = getCommandLineGroup(); ByteArrayOutputStream bout = new ByteArrayOutputStream(); HelpFormatter hf = new HelpFormatter(" ", null, null, getConsole().getTerminal().getWidth()); hf.setGroup(g);/*from w w w .j av a 2 s .c om*/ PrintWriter pw = new PrintWriter(new OutputStreamWriter(bout, charset)); hf.setPrintWriter(pw); hf.printHelp(); pw.flush(); // getConsole().println("\u001B[1mCommand Line:\u001B[0m "); getConsole().println(highlight("Command Line: ")); getConsole().println(" " + getName() + " " + getCommandLine()); getConsole().println(highlight("Usage:")); getConsole().println(new String(bout.toByteArray(), charset)); }
From source file:it.jnrpe.plugins.PluginProxy.java
/** * Prints the help related to the plugin to a specified output. * //from www.j av a 2s .c o m * @param out * the writer where the help should be written */ public void printHelp(final PrintWriter out) { HelpFormatter hf = new HelpFormatter(); StringBuilder sbDivider = new StringBuilder("="); while (sbDivider.length() < hf.getPageWidth()) { sbDivider.append('='); } out.println(sbDivider.toString()); out.println("PLUGIN NAME : " + proxyedPluginDefinition.getName()); if (description != null && description.trim().length() != 0) { out.println(sbDivider.toString()); out.println("Description : "); out.println(); out.println(description); } hf.setGroup(mainOptionsGroup); // hf.setHeader(m_pluginDef.getName()); hf.setDivider(sbDivider.toString()); hf.setPrintWriter(out); hf.print(); // hf.printHelp(m_pluginDef.getName(), m_Options); }
From source file:org.apache.mahout.common.CommandLineUtil.java
/** * Print the options supported by {@code GenericOptionsParser}. * In addition to the options supported by the job, passed in as the * group parameter.//from w w w . j av a 2 s . co m * * @param group job-specific command-line options. */ public static void printHelpWithGenericOptions(Group group) throws IOException { new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true); HelpFormatter formatter = new HelpFormatter(); formatter.setGroup(group); formatter.setPrintWriter(pw); formatter.setFooter( "Specify HDFS directories while running on hadoop; else specify local file system directories"); formatter.print(); }
From source file:org.apache.mahout.common.CommandLineUtil.java
public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException { new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true); HelpFormatter formatter = new HelpFormatter(); formatter.setGroup(group);/*w w w .j a v a 2s . co m*/ formatter.setPrintWriter(pw); formatter.setException(oe); formatter.print(); }
From source file:org.opencloudengine.flamingo.mapreduce.util.CommandLineUtil.java
public static void printHelpWithGenericOptions(Group group) throws IOException { Options ops = new Options(); new GenericOptionsParser(new Configuration(), ops, new String[0]); org.apache.commons.cli.HelpFormatter fmt = new org.apache.commons.cli.HelpFormatter(); fmt.printHelp("<command> [Generic Options] [Job-Specific Options]", "Generic Options:", ops, ""); PrintWriter pw = new PrintWriter(System.out, true); HelpFormatter formatter = new HelpFormatter(); formatter.setGroup(group);/*from w ww. j a v a2s . c om*/ formatter.setPrintWriter(pw); formatter.printHelp(); formatter.setFooter( "Hadoop Job? ? HDFS ? ? ."); formatter.printFooter(); pw.flush(); }
From source file:org.opencloudengine.flamingo.mapreduce.util.CommandLineUtil.java
public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException { Options ops = new Options(); new GenericOptionsParser(new Configuration(), ops, new String[0]); org.apache.commons.cli.HelpFormatter fmt = new org.apache.commons.cli.HelpFormatter(); fmt.printHelp("<command> [Generic Options] [Job-Specific Options]", "Generic Options:", ops, ""); PrintWriter pw = new PrintWriter(System.out, true); HelpFormatter formatter = new HelpFormatter(); formatter.setGroup(group);/*from w w w. ja v a2 s . c om*/ formatter.setPrintWriter(pw); formatter.setException(oe); formatter.print(); pw.flush(); }