equal
deleted
inserted
replaced
22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 package jdk.jpackage.internal; |
25 package jdk.jpackage.internal; |
26 |
26 |
27 import jdk.jpackage.internal.BundlerType; |
|
28 import jdk.jpackage.internal.BundleParams; |
|
29 |
|
30 import java.io.File; |
27 import java.io.File; |
31 import java.io.FileInputStream; |
28 import java.io.FileInputStream; |
32 import java.io.IOException; |
29 import java.io.IOException; |
33 import java.nio.file.Files; |
30 import java.nio.file.Files; |
34 import java.nio.file.Path; |
31 import java.nio.file.Path; |
154 |
151 |
155 public Arguments(String[] args) { |
152 public Arguments(String[] args) { |
156 initArgumentList(args); |
153 initArgumentList(args); |
157 } |
154 } |
158 |
155 |
|
156 // CLIOptions is public for DeployParamsTest |
159 public enum CLIOptions { |
157 public enum CLIOptions { |
160 CREATE_IMAGE(IMAGE_MODE, OptionCategories.MODE, () -> { |
158 CREATE_IMAGE(IMAGE_MODE, OptionCategories.MODE, () -> { |
161 context().bundleType = BundlerType.IMAGE; |
159 context().bundleType = BundlerType.IMAGE; |
162 context().deployParams.setTargetFormat("image"); |
160 context().deployParams.setTargetFormat("image"); |
163 setOptionValue(IMAGE_MODE, true); |
161 setOptionValue(IMAGE_MODE, true); |
427 this.shortId = shortId; |
425 this.shortId = shortId; |
428 this.action = action; |
426 this.action = action; |
429 this.category = category; |
427 this.category = category; |
430 } |
428 } |
431 |
429 |
432 public static void setContext(Arguments context) { |
430 static void setContext(Arguments context) { |
433 argContext = context; |
431 argContext = context; |
434 } |
432 } |
435 |
433 |
436 private static Arguments context() { |
434 private static Arguments context() { |
437 if (argContext != null) { |
435 if (argContext != null) { |
443 |
441 |
444 public String getId() { |
442 public String getId() { |
445 return this.id; |
443 return this.id; |
446 } |
444 } |
447 |
445 |
448 public String getIdWithPrefix() { |
446 String getIdWithPrefix() { |
449 String prefix = isMode() ? "create-" : "--"; |
447 String prefix = isMode() ? "create-" : "--"; |
450 return prefix + this.id; |
448 return prefix + this.id; |
451 } |
449 } |
452 |
450 |
453 public String getShortIdWithPrefix() { |
451 String getShortIdWithPrefix() { |
454 return this.shortId == null ? null : "-" + this.shortId; |
452 return this.shortId == null ? null : "-" + this.shortId; |
455 } |
453 } |
456 |
454 |
457 public void execute() { |
455 void execute() { |
458 if (action != null) { |
456 if (action != null) { |
459 action.execute(); |
457 action.execute(); |
460 } else { |
458 } else { |
461 defaultAction(); |
459 defaultAction(); |
462 } |
460 } |
463 } |
461 } |
464 |
462 |
465 public boolean isMode() { |
463 boolean isMode() { |
466 return category == OptionCategories.MODE; |
464 return category == OptionCategories.MODE; |
467 } |
465 } |
468 |
466 |
469 public OptionCategories getCategory() { |
467 OptionCategories getCategory() { |
470 return category; |
468 return category; |
471 } |
469 } |
472 |
470 |
473 private void defaultAction() { |
471 private void defaultAction() { |
474 context().deployParams.addBundleArgument(id, popArg()); |
472 context().deployParams.addBundleArgument(id, popArg()); |
500 private static boolean hasNextArg() { |
498 private static boolean hasNextArg() { |
501 return context().pos < context().argList.size(); |
499 return context().pos < context().argList.size(); |
502 } |
500 } |
503 } |
501 } |
504 |
502 |
505 public enum OptionCategories { |
503 enum OptionCategories { |
506 MODE, |
504 MODE, |
507 MODULAR, |
505 MODULAR, |
508 PROPERTY, |
506 PROPERTY, |
509 PLATFORM_MAC, |
507 PLATFORM_MAC, |
510 PLATFORM_WIN, |
508 PLATFORM_WIN, |
798 } |
796 } |
799 deployParams.addBundleArgument( |
797 deployParams.addBundleArgument( |
800 StandardBundlerParam.CLASSPATH.getID(), classpath); |
798 StandardBundlerParam.CLASSPATH.getID(), classpath); |
801 } |
799 } |
802 |
800 |
803 public static boolean isCLIOption(String arg) { |
801 static boolean isCLIOption(String arg) { |
804 return toCLIOption(arg) != null; |
802 return toCLIOption(arg) != null; |
805 } |
803 } |
806 |
804 |
807 public static CLIOptions toCLIOption(String arg) { |
805 static CLIOptions toCLIOption(String arg) { |
808 CLIOptions option; |
806 CLIOptions option; |
809 if ((option = argIds.get(arg)) == null) { |
807 if ((option = argIds.get(arg)) == null) { |
810 option = argShortIds.get(arg); |
808 option = argShortIds.get(arg); |
811 } |
809 } |
812 return option; |
810 return option; |
926 } |
924 } |
927 } catch (IOException ignore) {} |
925 } catch (IOException ignore) {} |
928 return null; |
926 return null; |
929 } |
927 } |
930 |
928 |
931 public static boolean isJreInstaller() { |
929 static boolean isJreInstaller() { |
932 return jreInstaller; |
930 return jreInstaller; |
933 } |
931 } |
934 } |
932 } |