author | goetz |
Tue, 16 Jan 2018 08:48:34 +0100 | |
changeset 48543 | 7067fe4e054e |
parent 47216 | 71c04702a3d5 |
child 50603 | 95c0644a1c47 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
48543
7067fe4e054e
8189102: All tools should support -?, -h and --help
goetz
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
36511 | 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 |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.tools.jar; |
|
27 |
||
28 |
import java.io.File; |
|
29 |
import java.io.PrintStream; |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
40261
diff
changeset
|
30 |
import java.io.PrintWriter; |
36511 | 31 |
import java.lang.module.ModuleFinder; |
32 |
import java.lang.module.ModuleDescriptor.Version; |
|
33 |
import java.nio.file.Path; |
|
34 |
import java.nio.file.Paths; |
|
35 |
import java.util.regex.Pattern; |
|
36 |
import java.util.regex.PatternSyntaxException; |
|
43109 | 37 |
|
38 |
import jdk.internal.module.ModulePath; |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
39 |
import jdk.internal.module.ModuleResolution; |
36511 | 40 |
|
41 |
/** |
|
42 |
* Parser for GNU Style Options. |
|
43 |
*/ |
|
44 |
class GNUStyleOptions { |
|
45 |
||
46 |
static class BadArgs extends Exception { |
|
47 |
static final long serialVersionUID = 0L; |
|
48 |
||
49 |
boolean showUsage; |
|
50 |
||
51 |
BadArgs(String key, String arg) { super(Main.formatMsg(key, arg)); } |
|
52 |
BadArgs(String key) { super(Main.getMsg(key)); } |
|
53 |
||
54 |
BadArgs showUsage(boolean b) { |
|
55 |
showUsage = b; |
|
56 |
return this; |
|
57 |
} |
|
58 |
} |
|
59 |
||
60 |
static Option[] recognizedOptions = { |
|
61 |
// Main operations |
|
62 |
new Option(false, OptionType.MAIN_OPERATION, "--create", "-c") { |
|
63 |
void process(Main tool, String opt, String arg) throws BadArgs { |
|
42463
39c0bbf9d03c
8170952: jar's usage message output need some cleanup
sherman
parents:
41489
diff
changeset
|
64 |
if (tool.iflag || tool.tflag || tool.uflag || tool.xflag || tool.dflag) |
36511 | 65 |
throw new BadArgs("error.multiple.main.operations").showUsage(true); |
66 |
tool.cflag = true; |
|
67 |
} |
|
68 |
}, |
|
69 |
new Option(true, OptionType.MAIN_OPERATION, "--generate-index", "-i") { |
|
70 |
void process(Main tool, String opt, String arg) throws BadArgs { |
|
42463
39c0bbf9d03c
8170952: jar's usage message output need some cleanup
sherman
parents:
41489
diff
changeset
|
71 |
if (tool.cflag || tool.tflag || tool.uflag || tool.xflag || tool.dflag) |
36511 | 72 |
throw new BadArgs("error.multiple.main.operations").showUsage(true); |
73 |
tool.iflag = true; |
|
74 |
tool.rootjar = arg; |
|
75 |
} |
|
76 |
}, |
|
77 |
new Option(false, OptionType.MAIN_OPERATION, "--list", "-t") { |
|
78 |
void process(Main tool, String opt, String arg) throws BadArgs { |
|
42463
39c0bbf9d03c
8170952: jar's usage message output need some cleanup
sherman
parents:
41489
diff
changeset
|
79 |
if (tool.cflag || tool.iflag || tool.uflag || tool.xflag || tool.dflag) |
36511 | 80 |
throw new BadArgs("error.multiple.main.operations").showUsage(true); |
81 |
tool.tflag = true; |
|
82 |
} |
|
83 |
}, |
|
84 |
new Option(false, OptionType.MAIN_OPERATION, "--update", "-u") { |
|
85 |
void process(Main tool, String opt, String arg) throws BadArgs { |
|
42463
39c0bbf9d03c
8170952: jar's usage message output need some cleanup
sherman
parents:
41489
diff
changeset
|
86 |
if (tool.cflag || tool.iflag || tool.tflag || tool.xflag || tool.dflag) |
36511 | 87 |
throw new BadArgs("error.multiple.main.operations").showUsage(true); |
88 |
tool.uflag = true; |
|
89 |
} |
|
90 |
}, |
|
91 |
new Option(false, OptionType.MAIN_OPERATION, "--extract", "-x") { |
|
92 |
void process(Main tool, String opt, String arg) throws BadArgs { |
|
42463
39c0bbf9d03c
8170952: jar's usage message output need some cleanup
sherman
parents:
41489
diff
changeset
|
93 |
if (tool.cflag || tool.iflag || tool.tflag || tool.uflag || tool.dflag) |
36511 | 94 |
throw new BadArgs("error.multiple.main.operations").showUsage(true); |
95 |
tool.xflag = true; |
|
96 |
} |
|
97 |
}, |
|
44267
00898a596f31
8176772: jar tool support to report automatic module names
chegar
parents:
43805
diff
changeset
|
98 |
new Option(false, OptionType.MAIN_OPERATION, "--describe-module", "-d") { |
36511 | 99 |
void process(Main tool, String opt, String arg) throws BadArgs { |
100 |
if (tool.cflag || tool.iflag || tool.tflag || tool.uflag || tool.xflag) |
|
101 |
throw new BadArgs("error.multiple.main.operations").showUsage(true); |
|
42463
39c0bbf9d03c
8170952: jar's usage message output need some cleanup
sherman
parents:
41489
diff
changeset
|
102 |
tool.dflag = true; |
36511 | 103 |
} |
104 |
}, |
|
105 |
||
106 |
// Additional options |
|
107 |
new Option(true, OptionType.ANY, "--file", "-f") { |
|
108 |
void process(Main jartool, String opt, String arg) { |
|
109 |
jartool.fname = arg; |
|
110 |
} |
|
111 |
}, |
|
112 |
new Option(false, OptionType.ANY, "--verbose", "-v") { |
|
113 |
void process(Main jartool, String opt, String arg) { |
|
114 |
jartool.vflag = true; |
|
115 |
} |
|
116 |
}, |
|
117 |
new Option(false, OptionType.CREATE, "--normalize", "-n") { |
|
118 |
void process(Main jartool, String opt, String arg) { |
|
119 |
jartool.nflag = true; |
|
120 |
} |
|
43805
9051877afb06
8165035: jar --help-extra should provide information on the -n/--normalize option
psandoz
parents:
43712
diff
changeset
|
121 |
boolean isExtra() { return true; } |
36511 | 122 |
}, |
123 |
new Option(true, OptionType.CREATE_UPDATE, "--main-class", "-e") { |
|
124 |
void process(Main jartool, String opt, String arg) { |
|
125 |
jartool.ename = arg; |
|
126 |
} |
|
127 |
}, |
|
128 |
new Option(true, OptionType.CREATE_UPDATE, "--manifest", "-m") { |
|
129 |
void process(Main jartool, String opt, String arg) { |
|
130 |
jartool.mname = arg; |
|
131 |
} |
|
132 |
}, |
|
133 |
new Option(false, OptionType.CREATE_UPDATE, "--no-manifest", "-M") { |
|
134 |
void process(Main jartool, String opt, String arg) { |
|
135 |
jartool.Mflag = true; |
|
136 |
} |
|
137 |
}, |
|
138 |
new Option(true, OptionType.CREATE_UPDATE, "--module-version") { |
|
139 |
void process(Main jartool, String opt, String arg) { |
|
140 |
jartool.moduleVersion = Version.parse(arg); |
|
141 |
} |
|
142 |
}, |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
143 |
new Option(true, OptionType.CREATE_UPDATE, "--hash-modules") { |
36511 | 144 |
void process(Main jartool, String opt, String arg) throws BadArgs { |
145 |
try { |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
146 |
jartool.modulesToHash = Pattern.compile(arg); |
36511 | 147 |
} catch (PatternSyntaxException e) { |
148 |
throw new BadArgs("err.badpattern", arg).showUsage(true); |
|
149 |
} |
|
150 |
} |
|
151 |
}, |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
152 |
new Option(true, OptionType.CREATE_UPDATE, "--module-path", "-p") { |
36511 | 153 |
void process(Main jartool, String opt, String arg) { |
154 |
String[] dirs = arg.split(File.pathSeparator); |
|
155 |
Path[] paths = new Path[dirs.length]; |
|
156 |
int i = 0; |
|
157 |
for (String dir : dirs) { |
|
158 |
paths[i++] = Paths.get(dir); |
|
159 |
} |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
43109
diff
changeset
|
160 |
jartool.moduleFinder = ModulePath.of(Runtime.version(), true, paths); |
36511 | 161 |
} |
162 |
}, |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
163 |
new Option(false, OptionType.CREATE_UPDATE, "--do-not-resolve-by-default") { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
164 |
void process(Main jartool, String opt, String arg) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
165 |
ModuleResolution mres = jartool.moduleResolution; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
166 |
jartool.moduleResolution = mres.withDoNotResolveByDefault(); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
167 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
168 |
boolean isExtra() { return true; } |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
169 |
}, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
170 |
new Option(true, OptionType.CREATE_UPDATE, "--warn-if-resolved") { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
171 |
void process(Main jartool, String opt, String arg) throws BadArgs { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
172 |
ModuleResolution mres = ModuleResolution.empty(); |
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
173 |
if (jartool.moduleResolution.doNotResolveByDefault()) { |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
174 |
mres.withDoNotResolveByDefault(); |
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
175 |
} |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
176 |
if (arg.equals("deprecated")) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
177 |
jartool.moduleResolution = mres.withDeprecated(); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
178 |
} else if (arg.equals("deprecated-for-removal")) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
179 |
jartool.moduleResolution = mres.withDeprecatedForRemoval(); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
180 |
} else if (arg.equals("incubating")) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
181 |
jartool.moduleResolution = mres.withIncubating(); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
182 |
} else { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
183 |
throw new BadArgs("error.bad.reason", arg); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
184 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
185 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
186 |
boolean isExtra() { return true; } |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
187 |
}, |
36511 | 188 |
new Option(false, OptionType.CREATE_UPDATE_INDEX, "--no-compress", "-0") { |
189 |
void process(Main jartool, String opt, String arg) { |
|
190 |
jartool.flag0 = true; |
|
191 |
} |
|
192 |
}, |
|
193 |
||
194 |
// Hidden options |
|
195 |
new Option(false, OptionType.OTHER, "-P") { |
|
196 |
void process(Main jartool, String opt, String arg) { |
|
197 |
jartool.pflag = true; |
|
198 |
} |
|
199 |
boolean isHidden() { return true; } |
|
200 |
}, |
|
201 |
||
202 |
// Other options |
|
48543
7067fe4e054e
8189102: All tools should support -?, -h and --help
goetz
parents:
47216
diff
changeset
|
203 |
new Option(true, true, OptionType.OTHER, "--help", "-h", "-?") { |
36511 | 204 |
void process(Main jartool, String opt, String arg) throws BadArgs { |
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
205 |
if (jartool.info == null) { |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
206 |
if (arg == null) { |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
207 |
jartool.info = GNUStyleOptions::printHelp; // Main.Info.HELP; |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
208 |
return; |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
209 |
} |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
210 |
if (!arg.equals("compat")) |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
211 |
throw new BadArgs("error.illegal.option", arg).showUsage(true); |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
212 |
// jartool.info = Main.Info.COMPAT_HELP; |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
213 |
jartool.info = GNUStyleOptions::printCompatHelp; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
214 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
215 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
216 |
}, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
217 |
new Option(false, OptionType.OTHER, "--help-extra") { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
218 |
void process(Main jartool, String opt, String arg) throws BadArgs { |
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
219 |
jartool.info = GNUStyleOptions::printHelpExtra; |
36511 | 220 |
} |
221 |
}, |
|
222 |
new Option(false, OptionType.OTHER, "--version") { |
|
223 |
void process(Main jartool, String opt, String arg) { |
|
224 |
if (jartool.info == null) |
|
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
225 |
jartool.info = GNUStyleOptions::printVersion; |
36511 | 226 |
} |
227 |
} |
|
228 |
}; |
|
229 |
||
230 |
enum OptionType { |
|
231 |
MAIN_OPERATION("main"), |
|
232 |
ANY("any"), |
|
233 |
CREATE("create"), |
|
234 |
CREATE_UPDATE("create.update"), |
|
235 |
CREATE_UPDATE_INDEX("create.update.index"), |
|
236 |
OTHER("other"); |
|
237 |
||
238 |
/** Resource lookup section prefix. */ |
|
239 |
final String name; |
|
240 |
||
241 |
OptionType(String name) { this.name = name; } |
|
242 |
} |
|
243 |
||
244 |
static abstract class Option { |
|
245 |
final boolean hasArg; |
|
246 |
final boolean argIsOptional; |
|
247 |
final String[] aliases; |
|
248 |
final OptionType type; |
|
249 |
||
250 |
Option(boolean hasArg, OptionType type, String... aliases) { |
|
251 |
this(hasArg, false, type, aliases); |
|
252 |
} |
|
253 |
||
254 |
Option(boolean hasArg, boolean argIsOptional, OptionType type, String... aliases) { |
|
255 |
this.hasArg = hasArg; |
|
256 |
this.argIsOptional = argIsOptional; |
|
257 |
this.type = type; |
|
258 |
this.aliases = aliases; |
|
259 |
} |
|
260 |
||
261 |
boolean isHidden() { return false; } |
|
262 |
||
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
263 |
boolean isExtra() { return false; } |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
264 |
|
36511 | 265 |
boolean matches(String opt) { |
266 |
for (String a : aliases) { |
|
267 |
if (a.equals(opt)) { |
|
268 |
return true; |
|
269 |
} else if (opt.startsWith("--") && hasArg && opt.startsWith(a + "=")) { |
|
270 |
return true; |
|
271 |
} else if (opt.startsWith("--help") && opt.startsWith(a + ":")) { |
|
272 |
return true; |
|
273 |
} |
|
274 |
} |
|
275 |
return false; |
|
276 |
} |
|
277 |
||
278 |
abstract void process(Main jartool, String opt, String arg) throws BadArgs; |
|
279 |
} |
|
280 |
||
281 |
static int parseOptions(Main jartool, String[] args) throws BadArgs { |
|
282 |
int count = 0; |
|
283 |
if (args.length == 0) { |
|
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
284 |
jartool.info = GNUStyleOptions::printUsageTryHelp; // never be here |
36511 | 285 |
return 0; |
286 |
} |
|
287 |
||
288 |
// process options |
|
289 |
for (; count < args.length; count++) { |
|
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
290 |
if (args[count].charAt(0) != '-' || args[count].equals("-C") || |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
291 |
args[count].equals("--release")) |
36511 | 292 |
break; |
293 |
||
294 |
String name = args[count]; |
|
295 |
Option option = getOption(name); |
|
296 |
String param = null; |
|
297 |
if (option.hasArg) { |
|
298 |
if (name.startsWith("--help")) { // "special" optional separator |
|
299 |
if (name.indexOf(':') > 0) { |
|
300 |
param = name.substring(name.indexOf(':') + 1, name.length()); |
|
301 |
} |
|
302 |
} else if (name.startsWith("--") && name.indexOf('=') > 0) { |
|
303 |
param = name.substring(name.indexOf('=') + 1, name.length()); |
|
304 |
} else if (count + 1 < args.length) { |
|
305 |
param = args[++count]; |
|
306 |
} |
|
307 |
if (!option.argIsOptional && |
|
308 |
(param == null || param.isEmpty() || param.charAt(0) == '-')) { |
|
309 |
throw new BadArgs("error.missing.arg", name).showUsage(true); |
|
310 |
} |
|
311 |
} |
|
312 |
option.process(jartool, name, param); |
|
313 |
} |
|
314 |
||
315 |
return count; |
|
316 |
} |
|
317 |
||
318 |
private static Option getOption(String name) throws BadArgs { |
|
319 |
for (Option o : recognizedOptions) { |
|
320 |
if (o.matches(name)) { |
|
321 |
return o; |
|
322 |
} |
|
323 |
} |
|
324 |
throw new BadArgs("error.unrecognized.option", name).showUsage(true); |
|
325 |
} |
|
326 |
||
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
327 |
static void printHelpExtra(PrintWriter out) { |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
328 |
printHelp0(out, true); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
329 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
330 |
|
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
331 |
static void printHelp(PrintWriter out) { |
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
332 |
printHelp0(out, false); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
333 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
334 |
|
43095
336dfda4ae89
8172432: jar cleanup/update for module and mrm jar
sherman
parents:
42703
diff
changeset
|
335 |
private static void printHelp0(PrintWriter out, boolean printExtra) { |
36511 | 336 |
out.format("%s%n", Main.getMsg("main.help.preopt")); |
337 |
for (OptionType type : OptionType.values()) { |
|
338 |
boolean typeHeadingWritten = false; |
|
339 |
||
340 |
for (Option o : recognizedOptions) { |
|
341 |
if (!o.type.equals(type)) |
|
342 |
continue; |
|
343 |
String name = o.aliases[0].substring(1); // there must always be at least one name |
|
344 |
name = name.charAt(0) == '-' ? name.substring(1) : name; |
|
345 |
if (o.isHidden() || name.equals("h")) { |
|
346 |
continue; |
|
347 |
} |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
348 |
if (o.isExtra() && !printExtra) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
349 |
continue; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42463
diff
changeset
|
350 |
} |
36511 | 351 |
if (!typeHeadingWritten) { |
352 |
out.format("%n%s%n", Main.getMsg("main.help.opt." + type.name)); |
|
353 |
typeHeadingWritten = true; |
|
354 |
} |
|
355 |
out.format("%s%n", Main.getMsg("main.help.opt." + type.name + "." + name)); |
|
356 |
} |
|
357 |
} |
|
358 |
out.format("%n%s%n%n", Main.getMsg("main.help.postopt")); |
|
359 |
} |
|
360 |
||
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
40261
diff
changeset
|
361 |
static void printCompatHelp(PrintWriter out) { |
36511 | 362 |
out.format("%s%n", Main.getMsg("usage.compat")); |
363 |
} |
|
364 |
||
42463
39c0bbf9d03c
8170952: jar's usage message output need some cleanup
sherman
parents:
41489
diff
changeset
|
365 |
static void printUsageTryHelp(PrintWriter out) { |
36511 | 366 |
out.format("%s%n", Main.getMsg("main.usage.summary.try")); |
367 |
} |
|
368 |
||
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
40261
diff
changeset
|
369 |
static void printVersion(PrintWriter out) { |
36511 | 370 |
out.format("%s %s%n", "jar", System.getProperty("java.version")); |
371 |
} |
|
372 |
} |