Interface Option

All Known Implementing Classes:
Options

public interface Option
  • Method Details

    • setStopOnBadOption

      Option setStopOnBadOption(boolean stopOnBadOption)
      stop parsing on the first unknown option. This allows one parser to get its own options and then pass the remaining options to another parser.
      Parameters:
      stopOnBadOption -
    • setOptionsFirst

      Option setOptionsFirst(boolean optionsFirst)
      require options to precede args. Default is false, so options can appear between or after args.
      Parameters:
      optionsFirst -
    • parse

      Option parse(List<? extends Object> argv, boolean skipArg0)
      parse arguments. If skipArgv0 is true, then parsing begins at arg1. This allows for commands where argv0 is the command name rather than a real argument.
      Parameters:
      argv -
      skipArg0 -
      Returns:
    • parse

      Option parse(List<? extends Object> argv)
      parse arguments.
    • parse

      Option parse(Object[] argv, boolean skipArg0)
      parse arguments.
    • parse

      Option parse(Object[] argv)
      parse arguments.
    • isSet

      boolean isSet(String name)
      test whether specified option has been explicitly set.
      Parameters:
      name -
      Returns:
    • get

      String get(String name)
      get value of named option. If multiple options given, this method returns the last one. Use getList(String) to get all values.
      Parameters:
      name -
      Returns:
      Throws:
      IllegalArgumentException - if value is not a String.
    • getList

      List<String> getList(String name)
      get list of all values for named option.
      Parameters:
      name -
      Returns:
      empty list if option not given and no default specified.
      Throws:
      IllegalArgumentException - if all values are not Strings.
    • getObject

      Object getObject(String name)
      get value of named option as an Object. If multiple options given, this method returns the last one. Use getObjectList(String) to get all values.
      Parameters:
      name -
      Returns:
    • getObjectList

      List<Object> getObjectList(String name)
      get list of all Object values for named option.
      Parameters:
      name -
      Returns:
    • getNumber

      int getNumber(String name)
      get value of named option as a Number.
      Parameters:
      name -
      Returns:
      Throws:
      IllegalArgumentException - if argument is not a Number.
    • args

      List<String> args()
      get remaining non-options args as Strings.
      Returns:
      Throws:
      IllegalArgumentException - if args are not Strings.
    • argObjects

      List<Object> argObjects()
      get remaining non-options args as Objects.
      Returns:
    • usage

      void usage()
      print usage message to System.err.
    • usageError

      IllegalArgumentException usageError(String error)
      print specified usage error to System.err. You should explicitly throw the returned exception.
      Parameters:
      error -
      Returns:
      IllegalArgumentException