private void printParser(ParserSpec parser, PrintWriter pw, String indent) { pw.printf("%sParserSpec:%n", indent); indent += " "; pw.printf("%sseparator: '%s'%n", indent, parser.separator()); pw.printf("%sendOfOptionsDelimiter: '%s'%n", indent, parser.endOfOptionsDelimiter()); pw.printf("%sexpandAtFiles: %s%n", indent, parser.expandAtFiles()); pw.printf("%satFileCommentChar: '%s'%n", indent, parser.atFileCommentChar()); pw.printf("%soverwrittenOptionsAllowed: %s%n", indent, parser.overwrittenOptionsAllowed()); pw.printf("%sunmatchedArgumentsAllowed: %s%n", indent, parser.unmatchedArgumentsAllowed()); pw.printf("%sunmatchedOptionsArePositionalParams: %s%n", indent, parser.unmatchedOptionsArePositionalParams()); pw.printf("%sstopAtUnmatched: %s%n", indent, parser.stopAtUnmatched()); pw.printf("%sstopAtPositional: %s%n", indent, parser.stopAtPositional()); pw.printf("%sposixClusteredShortOptionsAllowed: %s%n", indent, parser.posixClusteredShortOptionsAllowed()); pw.printf("%saritySatisfiedByAttachedOptionParam: %s%n", indent, parser.aritySatisfiedByAttachedOptionParam()); pw.printf("%scaseInsensitiveEnumValuesAllowed: %s%n", indent, parser.caseInsensitiveEnumValuesAllowed()); pw.printf("%scollectErrors: %s%n", indent, parser.collectErrors()); pw.printf("%slimitSplit: %s%n", indent, parser.limitSplit()); pw.printf("%stoggleBooleanFlags: %s%n", indent, parser.toggleBooleanFlags()); }
private void addOrExpand(String arg, List<String> arguments, Set<String> visited) { if (config().expandAtFiles() && !arg.equals("@") && arg.startsWith("@")) { arg = arg.substring(1); if (arg.startsWith("@")) { if (tracer.isInfo()) { tracer.info("Not expanding @-escaped argument %s (trimmed leading '@' char)%n", arg); } } else { if (tracer.isInfo()) { tracer.info("Expanding argument file @%s%n", arg); } expandArgumentFile(arg, arguments, visited); return; } } arguments.add(arg); } private void expandArgumentFile(String fileName, List<String> arguments, Set<String> visited) {
private void addOrExpand(String arg, List<String> arguments, Set<String> visited) { if (config().expandAtFiles() && !arg.equals("@") && arg.startsWith("@")) { arg = arg.substring(1); if (arg.startsWith("@")) { if (tracer.isInfo()) { tracer.info("Not expanding @-escaped argument %s (trimmed leading '@' char)%n", arg); } } else { if (tracer.isInfo()) { tracer.info("Expanding argument file @%s%n", arg); } expandArgumentFile(arg, arguments, visited); return; } } arguments.add(arg); } private void expandArgumentFile(String fileName, List<String> arguments, Set<String> visited) {
/** Returns whether arguments starting with {@code '@'} should be treated as the path to an argument file and its * contents should be expanded into separate arguments for each line in the specified file. * This property is {@code true} by default. * @return whether "argument files" or {@code @files} should be expanded into their content * @since 2.1 */ public boolean isExpandAtFiles() { return getCommandSpec().parser().expandAtFiles(); }
/** Sets whether arguments starting with {@code '@'} should be treated as the path to an argument file and its * contents should be expanded into separate arguments for each line in the specified file. ({@code true} by default.) * @param expandAtFiles whether "argument files" or {@code @files} should be expanded into their content * @return this {@code CommandLine} object, to allow method chaining * @since 2.1 */ public CommandLine setExpandAtFiles(boolean expandAtFiles) { getCommandSpec().parser().expandAtFiles(expandAtFiles); return this; }
/** Sets whether arguments starting with {@code '@'} should be treated as the path to an argument file and its * contents should be expanded into separate arguments for each line in the specified file. ({@code true} by default.) * @param expandAtFiles whether "argument files" or {@code @files} should be expanded into their content * @return this {@code CommandLine} object, to allow method chaining * @since 2.1 */ public CommandLine setExpandAtFiles(boolean expandAtFiles) { getCommandSpec().parser().expandAtFiles(expandAtFiles); return this; }
/** Returns whether arguments starting with {@code '@'} should be treated as the path to an argument file and its * contents should be expanded into separate arguments for each line in the specified file. * This property is {@code true} by default. * @return whether "argument files" or {@code @files} should be expanded into their content * @since 2.1 */ public boolean isExpandAtFiles() { return getCommandSpec().parser().expandAtFiles(); }