MCPcopy Create free account
hub / github.com/cbeust/jcommander / expandArgs

Method expandArgs

src/main/java/com/beust/jcommander/JCommander.java:445–476  ·  view source on GitHub ↗

Expand the command line parameters to take @ parameters into account. When @ is encountered, the content of the file that follows is inserted in the command line. @param originalArgv the original command line parameters @return the new and enriched command line parameters

(String[] originalArgv)

Source from the content-addressed store, hash-verified

443 * @return the new and enriched command line parameters
444 */
445 private String[] expandArgs(String[] originalArgv) {
446 List<String> vResult1 = Lists.newArrayList();
447
448 //
449 // Expand dynamic args
450 //
451 for (String arg : originalArgv) {
452 List<String> expanded = expandDynamicArg(arg);
453 vResult1.addAll(expanded);
454 }
455
456 // Expand separators
457 //
458 List<String> vResult2 = Lists.newArrayList();
459 vResult1.forEach(arg -> {
460 if (isOption(arg)) {
461 String sep = getSeparatorFor(arg);
462 if (!" ".equals(sep)) {
463 String[] sp = arg.split("[" + sep + "]", 2);
464 for (String ssp : sp) {
465 vResult2.add(ssp);
466 }
467 } else {
468 vResult2.add(arg);
469 }
470 } else {
471 vResult2.add(arg);
472 }
473 });
474
475 return vResult2.toArray(new String[vResult2.size()]);
476 }
477
478 private List<String> expandDynamicArg(String arg) {
479 for (ParameterDescription pd : descriptions.values()) {

Callers 1

parseMethod · 0.95

Calls 6

newArrayListMethod · 0.95
expandDynamicArgMethod · 0.95
isOptionMethod · 0.95
getSeparatorForMethod · 0.95
splitMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected