< prev index next >

src/jdk.jcmd/share/classes/sun/tools/jps/Arguments.java

Print this page
rev 47329 : 8189102: All tools should support -?, -h and --help


  35  *
  36  * @author Brian Doherty
  37  * @since 1.5
  38  */
  39 public class Arguments {
  40 
  41     private static final boolean debug = Boolean.getBoolean("jps.debug");
  42     private static final boolean printStackTrace = Boolean.getBoolean(
  43             "jps.printStackTrace");
  44 
  45     private boolean help;
  46     private boolean quiet;
  47     private boolean longPaths;
  48     private boolean vmArgs;
  49     private boolean vmFlags;
  50     private boolean mainArgs;
  51     private String hostname;
  52     private HostIdentifier hostId;
  53 
  54     public static void printUsage(PrintStream ps) {
  55       ps.println("usage: jps [-help]");
  56       ps.println("       jps [-q] [-mlvV] [<hostid>]");
  57       ps.println();
  58       ps.println("Definitions:");
  59       ps.println("    <hostid>:      <hostname>[:<port>]");

  60     }
  61 
  62     public Arguments(String[] args) throws IllegalArgumentException {
  63         int argc = 0;
  64 
  65         if (args.length == 1) {
  66             if ((args[0].compareTo("-?") == 0)



  67                     || (args[0].compareTo("-help")== 0)) {
  68               help = true;
  69               return;
  70             }
  71         }
  72 
  73         for (argc = 0; (argc < args.length) && (args[argc].startsWith("-"));
  74                 argc++) {
  75             String arg = args[argc];
  76 
  77             if (arg.compareTo("-q") == 0) {
  78               quiet = true;
  79             } else if (arg.startsWith("-")) {
  80                 for (int j = 1; j < arg.length(); j++) {
  81                     switch (arg.charAt(j)) {
  82                     case 'm':
  83                         mainArgs = true;
  84                         break;
  85                     case 'l':
  86                         longPaths = true;




  35  *
  36  * @author Brian Doherty
  37  * @since 1.5
  38  */
  39 public class Arguments {
  40 
  41     private static final boolean debug = Boolean.getBoolean("jps.debug");
  42     private static final boolean printStackTrace = Boolean.getBoolean(
  43             "jps.printStackTrace");
  44 
  45     private boolean help;
  46     private boolean quiet;
  47     private boolean longPaths;
  48     private boolean vmArgs;
  49     private boolean vmFlags;
  50     private boolean mainArgs;
  51     private String hostname;
  52     private HostIdentifier hostId;
  53 
  54     public static void printUsage(PrintStream ps) {
  55       ps.println("usage: jps [-? -h --help]");
  56       ps.println("       jps [-q] [-mlvV] [<hostid>]");
  57       ps.println();
  58       ps.println("Definitions:");
  59       ps.println("    <hostid>:      <hostname>[:<port>]");
  60       ps.println("    -? -h --help:  Prints this help message.");
  61     }
  62 
  63     public Arguments(String[] args) throws IllegalArgumentException {
  64         int argc = 0;
  65 
  66         if (args.length == 1) {
  67             if ((args[0].compareTo("-?") == 0)
  68                 || (args[0].compareTo("-h")== 0)
  69                 || (args[0].compareTo("--help")== 0)
  70                 // -help: legacy. Undocumented.
  71                 || (args[0].compareTo("-help")== 0)) {
  72               help = true;
  73               return;
  74             }
  75         }
  76 
  77         for (argc = 0; (argc < args.length) && (args[argc].startsWith("-"));
  78                 argc++) {
  79             String arg = args[argc];
  80 
  81             if (arg.compareTo("-q") == 0) {
  82               quiet = true;
  83             } else if (arg.startsWith("-")) {
  84                 for (int j = 1; j < arg.length(); j++) {
  85                     switch (arg.charAt(j)) {
  86                     case 'm':
  87                         mainArgs = true;
  88                         break;
  89                     case 'l':
  90                         longPaths = true;


< prev index next >