org.clapper.argot

ArgotParser

class ArgotParser extends AnyRef

ArgotParser is a command-line parser, with support for single-value and multi-value options, single-value and multi-value parameters, typed value, custom conversions (with suitable defaults), and extensibility.

An ArgotParser embodies a representation of the command line: its expected options and their value types, the expected positional parameters and their value types, the name of the program, and other values.

For complete details, see the Argot web site (linked below).

See also

the Argot web site

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ArgotParser
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ArgotParser(programName: String, compactUsage: Boolean = false, outputWidth: Int = 79, preUsage: Option[String] = scala.None, postUsage: Option[String] = scala.None, sortUsage: Boolean = true)

    programName

    the name of the program, for the usage message

    compactUsage

    force a more compact usage message

    outputWidth

    width of the output; used when wrapping the usage message

    preUsage

    optional message to issue before the usage message (e.g., a copyright and/or version string)

    postUsage

    optional message to issue after the usage message

    sortUsage

    If true (the default), the options are sorted alphabetically in the usage output. If false, they are displayed in the order they were created.

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. val allOptions: LinkedHashMap[String, CommandLineOption[_]]

    Attributes
    protected
  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def flag[T](name: String, default: T, description: String)(implicit convert: (Boolean, FlagOption[T]) ⇒ T): FlagOption[T]

    Define a flag option.

    Define a flag option. Flag options take no value parameters. Instead, a flag option is simply present or absent. Typically, flag options are associated with boolean value, though Argot will permit you to associate them with any type you choose.

    Flag options permit you to segregate the option names into on names and off names. With boolean flag options, the on names set the value to true, and the off names set the value to values. With typed flag options, what happens depends on the conversion function. Whatever the conversion function returns gets stored as the option's value.

    Flag conversion functions receive a boolean parameter, indicating whether an on option was seen (true) or an off option was seen (false). The built-in conversion functions for boolean flags simply return the value of the boolean, which is then stored in the (Boolean) flag option's value. However, it's perfectly reasonable to have flag options with other types. For instance, one could easily define a "Verbosity" flag option of type Int, where each on option increments the verbosity level and each off option decrements the value.

    T

    the type of the option's value, which will be stored in the FlagOption object's value field.

    name

    the name for the option that enables (turns on) the option. The name can be a single character (thus, "v" corresponds to "-v") or multiple characters ("verbose" for "--verbose").

    description

    a description for the option, for the usage message

    convert

    a function that will convert a boolean on/off value to type T. The function should throw ArgotConversionException on conversion error. For a boolean flag option , the implicit functions in the ArgotConverters module are often suitable.

    returns

    the FlagOption object that will contain the parsed value, as an Option[T] in the value field.

  13. def flag[T](namesOn: List[String], description: String)(implicit convert: (Boolean, FlagOption[T]) ⇒ T): FlagOption[T]

    Define a flag option.

    Define a flag option. Flag options take no value parameters. Instead, a flag option is simply present or absent. Typically, flag options are associated with boolean value, though Argot will permit you to associate them with any type you choose.

    Flag options permit you to segregate the option names into on names and off names. With boolean flag options, the on names set the value to true, and the off names set the value to values. With typed flag options, what happens depends on the conversion function. Whatever the conversion function returns gets stored as the option's value.

    Flag conversion functions receive a boolean parameter, indicating whether an on option was seen (true) or an off option was seen (false). The built-in conversion functions for boolean flags simply return the value of the boolean, which is then stored in the (Boolean) flag option's value. However, it's perfectly reasonable to have flag options with other types. For instance, one could easily define a "Verbosity" flag option of type Int, where each on option increments the verbosity level and each off option decrements the value.

    T

    the type of the option's value, which will be stored in the FlagOption object's value field.

    namesOn

    the names for the option that enable (turn on) the option. Each name can be a single character (thus, "v" corresponds to "-v") or multiple characters ("verbose" for "--verbose").

    description

    a description for the option, for the usage message

    convert

    a function that will convert a boolean on/off value to type T. The function should throw ArgotConversionException on conversion error. For a boolean flag option , the implicit functions in the ArgotConverters module are often suitable.

    returns

    the FlagOption object that will contain the parsed value, as an Option[T] in the value field.

  14. def flag[T](namesOn: List[String], namesOff: List[String], description: String)(implicit convert: (Boolean, FlagOption[T]) ⇒ T): FlagOption[T]

    Define a flag option.

    Define a flag option. Flag options take no value parameters. Instead, a flag option is simply present or absent. Typically, flag options are associated with boolean value, though Argot will permit you to associate them with any type you choose.

    Flag options permit you to segregate the option names into on names and off names. With boolean flag options, the on names set the value to true, and the off names set the value to values. With typed flag options, what happens depends on the conversion function. Whatever the conversion function returns gets stored as the option's value.

    Flag conversion functions receive a boolean parameter, indicating whether an on option was seen (true) or an off option was seen (false). The built-in conversion functions for boolean flags simply return the value of the boolean, which is then stored in the (Boolean) flag option's value. However, it's perfectly reasonable to have flag options with other types. For instance, one could easily define a "Verbosity" flag option of type Int, where each on option increments the verbosity level and each off option decrements the value.

    T

    the type of the option's value, which will be stored in the FlagOption object's value field.

    namesOn

    the names for the option that enable (turn on) the option. Each name can be a single character (thus, "v" corresponds to "-v") or multiple characters ("verbose" for "--verbose").

    namesOff

    the names for the option that disable (turn off) the option. Each name can be a single character (thus, "v" corresponds to "-v") or multiple characters ("verbose" for "--verbose").

    description

    a description for the option, for the usage message

    convert

    a function that will convert a boolean on/off value to type T. The function should throw ArgotConversionException on conversion error. For a boolean flag option , the implicit functions in the ArgotConverters module are often suitable.

    returns

    the FlagOption object that will contain the parsed value, as an Option[T] in the value field.

  15. val flags: LinkedHashSet[FlagOption[_]]

    Attributes
    protected
  16. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  19. val longNameMap: Map[String, CommandLineOption[_]]

    Attributes
    protected
  20. def multiOption[T](name: String, valueName: String, description: String)(implicit convert: (String, MultiValueOption[T]) ⇒ T): MultiValueOption[T]

    Define an option that takes a sequence of values of type T.

    Define an option that takes a sequence of values of type T. Each invocation of the option on the command line contributes a new value to the sequence. This short-hand method provides only one option name, as opposed to a list of option names.

    T

    the type of the option's value, which added to the the MultiValueOption object's value sequence field.

    name

    the name for the option. The name can be a single character (thus, "v" corresponds to "-v") or multiple characters ("verbose" for "--verbose").

    valueName

    a name to use for the associated value in the generated usage message

    description

    a description for the option, for the usage message

    convert

    a function that will convert a string value into type T. The function should throw ArgotConversionException on conversion error. For common types, the implicit functions in the ArgotConverters module are often suitable.

    returns

    the MultiValueOption object that will contain the parsed value(s), as a Seq[T] in the value field.

  21. def multiOption[T](names: List[String], valueName: String, description: String)(implicit convert: (String, MultiValueOption[T]) ⇒ T): MultiValueOption[T]

    Define an option that takes a sequence of values of type T.

    Define an option that takes a sequence of values of type T. Each invocation of the option on the command line contributes a new value to the sequence.

    T

    the type of the option's value, which added to the the MultiValueOption object's value sequence field.

    names

    the list of names for the option. Each name can be a single character (thus, "v" corresponds to "-v") or multiple characters ("verbose" for "--verbose").

    valueName

    a name to use for the associated value in the generated usage message

    description

    a description for the option, for the usage message

    convert

    a function that will convert a string value into type T. The function should throw ArgotConversionException on conversion error. For common types, the implicit functions in the ArgotConverters module are often suitable.

    returns

    the MultiValueOption object that will contain the parsed value(s), as a Seq[T] in the value field.

  22. def multiParameter[T](valueName: String, description: String, optional: Boolean)(implicit convert: (String, Parameter[T]) ⇒ T): MultiValueParameter[T]

    Define a positional parameter that can occur multiple times.

    Define a positional parameter that can occur multiple times. Only one such parameter can exist, and it must be the last parameter in the command line. See the class documentation for complete details.

    valueName

    the placeholder name for the parameter's value, for the usage message

    description

    textual description of the parameter

    optional

    whether or not the parameter is optional. Only one parameter may be optional, and it must be the last one.

    convert

    a function that will convert a string value for the parameter to an appropriate value of type T. The function should throw ArgotConversionException on conversion error.

    returns

    the MultiValueParameter object will contain the parsed values (as a Seq[T] in the value field).

  23. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  24. val nonFlags: LinkedHashSet[HasValue[_]]

    Attributes
    protected
  25. final def notify(): Unit

    Definition Classes
    AnyRef
  26. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  27. def option[T](name: String, valueName: String, description: String)(implicit convert: (String, SingleValueOption[T]) ⇒ T): SingleValueOption[T]

    Define an option that takes a single value of type T.

    Define an option that takes a single value of type T. This short-hand method provides only one option name, as opposed to a list of option names.

    T

    the type of the option's value, which will be stored in the SingleValueOption object's value field.

    name

    the name for the option. The name can be a single character (thus, "v" corresponds to "-v") or multiple characters ("verbose" for "--verbose").

    valueName

    a name to use for the associated value in the generated usage message

    description

    a description for the option, for the usage message

    convert

    a function that will convert a string value into type T. The function should throw ArgotConversionException on conversion error. For common types, the implicit functions in the ArgotConverters module are often suitable.

    returns

    the SingleValueOption object that will contain the parsed value, as an Option[T] in the value field.

  28. def option[T](names: List[String], valueName: String, description: String)(implicit convert: (String, SingleValueOption[T]) ⇒ T): SingleValueOption[T]

    Define an option that takes a single value of type T.

    Define an option that takes a single value of type T.

    T

    the type of the option's value, which will be stored in the SingleValueOption object's value field.

    names

    the list of names for the option. Each name can be a single character (thus, "v" corresponds to "-v") or multiple characters ("verbose" for "--verbose").

    valueName

    a name to use for the associated value in the generated usage message

    description

    a description for the option, for the usage message

    convert

    a function that will convert a string value into type T. The function should throw ArgotConversionException on conversion error. For common types, the implicit functions in the ArgotConverters module are often suitable.

    returns

    the SingleValueOption object that will contain the parsed value, as an Option[T] in the value field.

  29. def parameter[T](valueName: String, description: String, optional: Boolean)(implicit convert: (String, Parameter[T]) ⇒ T): SingleValueParameter[T]

    Define a positional parameter that has a single value.

    Define a positional parameter that has a single value. Positional parameters are parsed from the command line in the order they are added to the ArgotParser. See the class documentation for complete details.

    valueName

    the placeholder name for the parameter's value, for the usage message

    description

    textual description of the parameter

    optional

    whether or not the parameter is optional. Only one parameter may be optional, and it must be the last one.

    convert

    a function that will convert a string value for the parameter to an appropriate value of type T. The function should throw ArgotConversionException on conversion error.

    returns

    the SingleValueParameter object will contain the parsed value (as an Option[T] in the value field).

  30. val parameters: LinkedHashSet[Parameter[_]]

    Attributes
    protected
  31. def parse(args: List[String]): Unit

    Parse the specified array of command-line arguments, according to the parser's specification.

    Parse the specified array of command-line arguments, according to the parser's specification. A successful parse sets the various value objects returned by the specification methods.

    args

    the command line parameters

    Exceptions thrown
    ArgotException

    some other kind of fatal error

    ArgotUsageException

    user error on the command line; the exception contains the usage message

  32. def parse(args: Array[String]): Unit

    Parse the specified array of command-line arguments, according to the parser's specification.

    Parse the specified array of command-line arguments, according to the parser's specification. A successful parse sets the various value objects returned by the specification methods.

    args

    the command line parameters

    Exceptions thrown
    ArgotException

    some other kind of fatal error

    ArgotUsageException

    user error on the command line; the exception contains the usage message

  33. def parseLongOpt(a: List[String]): List[String]

  34. def reset(): Unit

    Resets the internal state of all contained options and parameters, undoing the effects of any parse operation.

  35. val shortNameMap: Map[Char, CommandLineOption[_]]

    Attributes
    protected
  36. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  37. def toString(): String

    Definition Classes
    AnyRef → Any
  38. def usage(message: String): Nothing

    Throws an ArgotUsageException containing the usage string.

    Throws an ArgotUsageException containing the usage string.

    message

    optional message to prefix the usage string.

    Exceptions thrown
    ArgotUsageException

    unconditionally

  39. def usage(): Nothing

    Throws an ArgotUsageException containing the usage string.

    Throws an ArgotUsageException containing the usage string.

    Exceptions thrown
    ArgotUsageException

    unconditionally

  40. def usageString(message: Option[String] = None): String

    Generate the usage string.

    Generate the usage string. This string is automatically included in any thrown ArgotUsageException.

    message

    optional message to prefix the usage string.

    returns

    the usage string, wrapped appropriately.

  41. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped