1 10 package org.apache.commons.cli; 11 12 17 public class HelpFormatterExamples 18 { 19 21 23 public static void main( String [] args ) 24 { 25 System.out.println("\n#\n# 'man' example\n#"); 26 manExample(); 27 33 } 34 35 static void manExample() 36 { 37 String cmdLine = 38 "man [-c|-f|-k|-w|-tZT device] [-adlhu7V] [-Mpath] [-Ppager] [-Slist] " + 39 "[-msystem] [-pstring] [-Llocale] [-eextension] [section] page ..."; 40 Options opts = 41 new Options(). 42 addOption("a", "all", false, "find all matching manual pages."). 43 addOption("d", "debug", false, "emit debugging messages."). 44 addOption("e", "extension", false, "limit search to extension type 'extension'."). 45 addOption("f", "whatis", false, "equivalent to whatis."). 46 addOption("k", "apropos", false, "equivalent to apropos."). 47 addOption("w", "location", false, "print physical location of man page(s)."). 48 addOption("l", "local-file", false, "interpret 'page' argument(s) as local filename(s)"). 49 addOption("u", "update", false, "force a cache consistency check."). 50 addOption("r", "prompt", true, "provide 'less' pager with prompt."). 52 addOption("c", "catman", false, "used by catman to reformat out of date cat pages."). 53 addOption("7", "ascii", false, "display ASCII translation or certain latin1 chars."). 54 addOption("t", "troff", false, "use troff format pages."). 55 addOption("T", "troff-device", true, "use groff with selected device."). 57 addOption("Z", "ditroff", false, "use groff with selected device."). 58 addOption("D", "default", false, "reset all options to their default values."). 59 addOption("M", "manpath", true, "set search path for manual pages to 'path'."). 61 addOption("P", "pager", true, "use program 'pager' to display output."). 63 addOption("S", "sections", true, "use colon separated section list."). 65 addOption("m", "systems", true, "search for man pages from other unix system(s)."). 67 addOption("L", "locale", true, "defaine the locale for this particular man search."). 69 addOption("p", "preprocessor", true, "string indicates which preprocessor to run.\n" + 71 " e - [n]eqn p - pic t - tbl\n" + 72 " g - grap r - refer v - vgrind"). 73 addOption("V", "version", false, "show version."). 74 addOption("h", "help", false, "show this usage message."); 75 76 HelpFormatter hf = new HelpFormatter(); 77 hf.printHelp(60, cmdLine, null, opts, null); 79 } 80 81 static void bzip2Example() 82 { 83 System.out.println( "Coming soon" ); 84 } 85 86 static void lsExample() 87 { 88 System.out.println( "Coming soon" ); 89 } 90 91 92 94 96 98 100 102 104 106 } 107 | Popular Tags |