コード例 #1
0
    @Override
    public ParserState onComplete() {
      if (getHasArgument() && values.isEmpty()) {
        throw new CommandLineArgumentException(
            String.format("No argument was provided for command-line option '%s'.", optionString));
      }

      ParsedCommandLineOption parsedOption = commandLine.addOption(optionString.option, option);
      if (values.size() + parsedOption.getValues().size() > 1
          && !option.getAllowsMultipleArguments()) {
        throw new CommandLineArgumentException(
            String.format(
                "Multiple arguments were provided for command-line option '%s'.", optionString));
      }
      for (String value : values) {
        parsedOption.addArgument(value);
      }
      if (option.getDeprecationWarning() != null) {
        deprecationPrinter.println(
            "The " + optionString + " option is deprecated - " + option.getDeprecationWarning());
      }

      for (CommandLineOption otherOption : option.getGroupWith()) {
        commandLine.removeOption(otherOption);
      }

      return state;
    }
コード例 #2
0
 @Override
 public ParserState onNonOption(String arg) {
   commandLine.addExtraValue(arg);
   return allowMixedOptions
       ? new AfterFirstSubCommand(commandLine)
       : new AfterOptions(commandLine);
 }
コード例 #3
0
 @Override
 public ParserState onComplete() {
   commandLine.addExtraValue(arg);
   return state;
 }
コード例 #4
0
 @Override
 public ParserState onNonOption(String arg) {
   commandLine.addExtraValue(arg);
   return this;
 }