< prev index next >

src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java

Print this page
rev 48495 : 8189102: All tools should support -?, -h and --help
Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini
   1 /*
   2  * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1127             if (o.matches(name)) {
1128                 return o;
1129             }
1130         }
1131         throw new BadArgs("err.unknown.option", name).showUsage(true);
1132     }
1133 
1134     private void reportError(String key, Object... args) {
1135         log.println(getMessage("error.prefix") + " " + getMessage(key, args));
1136     }
1137 
1138     void warning(String key, Object... args) {
1139         log.println(getMessage("warn.prefix") + " " + getMessage(key, args));
1140     }
1141 
1142     private void showHelp() {
1143         log.println(getMessage("main.usage", PROGNAME));
1144         for (Option o : recognizedOptions) {
1145             String name = o.aliases[0].substring(1); // there must always be at least one name
1146             name = name.charAt(0) == '-' ? name.substring(1) : name;
1147             if (o.isHidden() || name.equals("h") || name.startsWith("filter:")) {
1148                 continue;
1149             }
1150             log.println(getMessage("main.opt." + name));
1151         }
1152     }
1153 
1154     private void showVersion(boolean full) {
1155         log.println(version(full ? "full" : "release"));
1156     }
1157 
1158     private String version(String key) {
1159         // key=version:  mm.nn.oo[-milestone]
1160         // key=full:     mm.mm.oo[-milestone]-build
1161         if (ResourceBundleHelper.versionRB == null) {
1162             return System.getProperty("java.version");
1163         }
1164         try {
1165             return ResourceBundleHelper.versionRB.getString(key);
1166         } catch (MissingResourceException e) {
1167             return getMessage("version.unknown", System.getProperty("java.version"));


   1 /*
   2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1127             if (o.matches(name)) {
1128                 return o;
1129             }
1130         }
1131         throw new BadArgs("err.unknown.option", name).showUsage(true);
1132     }
1133 
1134     private void reportError(String key, Object... args) {
1135         log.println(getMessage("error.prefix") + " " + getMessage(key, args));
1136     }
1137 
1138     void warning(String key, Object... args) {
1139         log.println(getMessage("warn.prefix") + " " + getMessage(key, args));
1140     }
1141 
1142     private void showHelp() {
1143         log.println(getMessage("main.usage", PROGNAME));
1144         for (Option o : recognizedOptions) {
1145             String name = o.aliases[0].substring(1); // there must always be at least one name
1146             name = name.charAt(0) == '-' ? name.substring(1) : name;
1147             if (o.isHidden() || name.startsWith("filter:")) {
1148                 continue;
1149             }
1150             log.println(getMessage("main.opt." + name));
1151         }
1152     }
1153 
1154     private void showVersion(boolean full) {
1155         log.println(version(full ? "full" : "release"));
1156     }
1157 
1158     private String version(String key) {
1159         // key=version:  mm.nn.oo[-milestone]
1160         // key=full:     mm.mm.oo[-milestone]-build
1161         if (ResourceBundleHelper.versionRB == null) {
1162             return System.getProperty("java.version");
1163         }
1164         try {
1165             return ResourceBundleHelper.versionRB.getString(key);
1166         } catch (MissingResourceException e) {
1167             return getMessage("version.unknown", System.getProperty("java.version"));


< prev index next >