464 } |
464 } |
465 } |
465 } |
466 return pp; |
466 return pp; |
467 } |
467 } |
468 |
468 |
|
469 // used by jimage. Return unhandled arguments like "create", "describe". |
469 public List<String> handleOptions(T task, String[] args) throws BadArgs { |
470 public List<String> handleOptions(T task, String[] args) throws BadArgs { |
|
471 return handleOptions(task, args, true); |
|
472 } |
|
473 |
|
474 // used by jlink. No unhandled arguments like "create", "describe". |
|
475 void handleOptionsNoUnhandled(T task, String[] args) throws BadArgs { |
|
476 handleOptions(task, args, false); |
|
477 } |
|
478 |
|
479 // shared code that handles options for both jlink and jimage. jimage uses arguments like |
|
480 // "create", "describe" etc. as "task names". Those arguments are unhandled here and returned |
|
481 // as "unhandled arguments list". jlink does not want such arguments. "collectUnhandled" flag |
|
482 // tells whether to allow for unhandled arguments or not. |
|
483 private List<String> handleOptions(T task, String[] args, boolean collectUnhandled) throws BadArgs { |
470 // findbugs warning, copy instead of keeping a reference. |
484 // findbugs warning, copy instead of keeping a reference. |
471 command = Arrays.copyOf(args, args.length); |
485 command = Arrays.copyOf(args, args.length); |
472 |
486 |
473 // Must extract it prior to do any option analysis. |
487 // Must extract it prior to do any option analysis. |
474 // Required to interpret custom plugin options. |
488 // Required to interpret custom plugin options. |
497 } |
511 } |
498 } |
512 } |
499 String[] arr = new String[filteredArgs.size()]; |
513 String[] arr = new String[filteredArgs.size()]; |
500 args = filteredArgs.toArray(arr); |
514 args = filteredArgs.toArray(arr); |
501 |
515 |
502 List<String> rest = new ArrayList<>(); |
516 List<String> rest = collectUnhandled? new ArrayList<>() : null; |
503 // process options |
517 // process options |
504 for (int i = 0; i < args.length; i++) { |
518 for (int i = 0; i < args.length; i++) { |
505 if (!args[i].isEmpty() && args[i].charAt(0) == '-') { |
519 if (args[i].charAt(0) == '-') { |
506 String name = args[i]; |
520 String name = args[i]; |
507 PlugOption pluginOption = null; |
521 PlugOption pluginOption = null; |
508 Option<T> option = getOption(name); |
522 Option<T> option = getOption(name); |
509 if (option == null) { |
523 if (option == null) { |
510 pluginOption = pluginOptions.getOption(name); |
524 pluginOption = pluginOptions.getOption(name); |