< prev index next >

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

Print this page
rev 48074 : 8189102: All tools should support -?, -h and --help
Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini
   1 /*
   2  * Copyright (c) 2012, 2014, 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


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


   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


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


< prev index next >