protected void usage(ParseException e, boolean showHiddenOptions) { if (e != null) { System.err.println("Error parsing command line arguments: " + e.getMessage()); } Options opts = showHiddenOptions ? getAllOptions() : mOptions; PrintWriter pw = new PrintWriter(System.err, true); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( pw, formatter.getWidth(), getCommandUsage(), null, opts, formatter.getLeftPadding(), formatter.getDescPadding(), null); pw.flush(); String trailer = getTrailer(); if (trailer != null && trailer.length() > 0) { System.err.println(); System.err.println(trailer); } }
private void usage(ParseException e, boolean exit) { if (e != null) { System.err.println(e.getMessage()); System.err.println(); System.err.println(); } PrintWriter pw = new PrintWriter(System.err, true); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(80); formatter.printHelp( pw, formatter.getWidth(), getCommandUsage(), null, getOptions(false), formatter.getLeftPadding(), formatter.getDescPadding(), null); pw.flush(); System.err.println(); System.err.println("term filter: "); System.err.println( " - each f[n], t[n] pair represents a term filter, f[n], t[n] don't have to both exist"); System.err.println(" - f[n] represents a term field name, t[n] represents a term text"); System.err.println(" - the final filter is formed by ORing all term filters together"); System.err.println(" - maximum of " + NUM_TERM_FILTERS + " term filters are allowed"); System.err.println(); System.err.println(" examples:"); System.err.println(" -f1 l.content -t1 foo" + " (term l.content=foo)"); System.err.println( " -f2 from" + " (all terms with from as the field name)"); System.err.println(" -t3 bar" + " (all terms with bar as the text)"); System.err.println(); System.err.println(); System.err.println("Sample command lines:"); System.err.println( "zmjava com.zimbra.cs.index.LuceneViewer -a dump -i /opt/zimbra/index/0/2/index/0 -o /tmp/user1-index-dump.txt"); System.err.println( "zmjava com.zimbra.cs.index.LuceneViewer -a dump -v -f1 l.content -t1 jay -f2 subject -t2 howdy -i /opt/zimbra/index/0/2/index/0 -o /tmp/user1-index-dump.txt"); System.err.println( "zmjava com.zimbra.cs.index.LuceneViewer -a dump -f1 from [email protected] -i /opt/zimbra/index/0/2/index/0 -o /tmp/user1-index-dump.txt"); if (exit) { System.exit(1); } }
/** * Prints usage information. * * @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 <*****@*****.**>, license: GNU/GPL"); printWriter.close(); }