protected void handleConcatenatedOptions(String token) throws CLIException { for (int i = 1; i < token.length(); i++) { String ch = String.valueOf(token.charAt(i)); if (hasOptionWithShortName(ch)) { handleOption(getOption(ch)); if (current != null && token.length() != i + 1) { // add the trail as an argument of the option commandLine.addRawValue(current, token.substring(i + 1)); break; } } else { handleArgument(token); break; } } }
/** * Handles the following tokens: * <p/> * --L=V * -L=V * --l=V * -l=V * * @param token the command line token to handle */ private void handleLongOptionWithEqual(String token) throws CLIException { int pos = token.indexOf('='); String value = token.substring(pos + 1); String opt = token.substring(0, pos); List<Option> matchingOpts = getMatchingOptions(opt); if (matchingOpts.isEmpty()) { handleArgument(token); } else if (matchingOpts.size() > 1) { throw new AmbiguousOptionException(opt, matchingOpts); } else { Option option = matchingOpts.get(0); if (commandLine.acceptMoreValues(option)) { handleOption(option); commandLine.addRawValue(option, value); current = null; } else { throw new InvalidValueException(option, value); } } }
private void visit(String token) throws CLIException { this.token = token; if (skipParsing) { commandLine.addArgumentValue(token); } else if (token.equals("--")) { skipParsing = true; } else if (current != null && current.acceptValue() && isValue(token)) { commandLine.addRawValue(current, stripLeadingAndTrailingQuotes(token)); } else if (token.startsWith("--")) { handleLongOption(token); } else if (token.startsWith("-") && !"-".equals(token)) { handleShortAndLongOption(token); } else { handleArgument(token); } if (current != null && !commandLine.acceptMoreValues(current)) { current = null; } }
if (commandLine.acceptMoreValues(getOption(opt))) { handleOption(getOption(opt)); commandLine.addRawValue(getOption(opt), t.substring(opt.length())); current = null; } else { Option option = getOption(strip); handleOption(option); commandLine.addRawValue(current, t.substring(1)); current = null; } else { if (commandLine.acceptMoreValues(option)) { handleOption(option); commandLine.addRawValue(option, value); current = null; } else { commandLine.addRawValue(current, opt.substring(1) + "=" + value); current = null; } else {
protected void handleConcatenatedOptions(String token) throws CLIException { for (int i = 1; i < token.length(); i++) { String ch = String.valueOf(token.charAt(i)); if (hasOptionWithShortName(ch)) { handleOption(getOption(ch)); if (current != null && token.length() != i + 1) { // add the trail as an argument of the option commandLine.addRawValue(current, token.substring(i + 1)); break; } } else { handleArgument(token); break; } } }
/** * Handles the following tokens: * <p/> * --L=V * -L=V * --l=V * -l=V * * @param token the command line token to handle */ private void handleLongOptionWithEqual(String token) throws CLIException { int pos = token.indexOf('='); String value = token.substring(pos + 1); String opt = token.substring(0, pos); List<Option> matchingOpts = getMatchingOptions(opt); if (matchingOpts.isEmpty()) { handleArgument(token); } else if (matchingOpts.size() > 1) { throw new AmbiguousOptionException(opt, matchingOpts); } else { Option option = matchingOpts.get(0); if (commandLine.acceptMoreValues(option)) { handleOption(option); commandLine.addRawValue(option, value); current = null; } else { throw new InvalidValueException(option, value); } } }
private void visit(String token) throws CLIException { this.token = token; if (skipParsing) { commandLine.addArgumentValue(token); } else if (token.equals("--")) { skipParsing = true; } else if (current != null && current.acceptValue() && isValue(token)) { commandLine.addRawValue(current, stripLeadingAndTrailingQuotes(token)); } else if (token.startsWith("--")) { handleLongOption(token); } else if (token.startsWith("-") && !"-".equals(token)) { handleShortAndLongOption(token); } else { handleArgument(token); } if (current != null && !commandLine.acceptMoreValues(current)) { current = null; } }
if (commandLine.acceptMoreValues(getOption(opt))) { handleOption(getOption(opt)); commandLine.addRawValue(getOption(opt), t.substring(opt.length())); current = null; } else { Option option = getOption(strip); handleOption(option); commandLine.addRawValue(current, t.substring(1)); current = null; } else { if (commandLine.acceptMoreValues(option)) { handleOption(option); commandLine.addRawValue(option, value); current = null; } else { commandLine.addRawValue(current, opt.substring(1) + "=" + value); current = null; } else {