clam.getopt

package clam.getopt

A utility to sort and extract arguments from a set of parameter definitions.

Attributes

Members list

Concise view

Type members

Classlikes

case class Arg(nameUsed: String, arg: Option[String])

A known argument corresponding to a parameter

A known argument corresponding to a parameter

Attributes

arg

In case of a named param, the argument given after the name, if any. In case of a positional param, this value is always set.

nameUsed

In case of a named param, the actual name of the parameter used. This is used to disambiguate between aliases in certain situations, for example in error reporting.

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
case class Param(name: String, aliases: Seq[String], flag: Boolean, positionalRepeats: Boolean, endOfNamed: Boolean)

A parameter definition for a GetOpt instance.

A parameter definition for a GetOpt instance.

The name determines the type of parameter: if it starts with "-", then the parameter will be considered named, otherwise it will be considered positional.

A named parameter can occur in any position on the command line and its arguments will be taken as the word after encountering the name. Positional parameters always take an argument based on the position in which they are declared.

E.g. --named1 arg1 pos1 -named2 arg2 --named3=arg3 pos, would assign the arguments to parameters in the following way:

  • named arguments:
  • --named1 is assigned arg1
  • -named2 is assigned arg2
  • --named3 is assigned arg3
  • positional arguments:
  • first positional parameter is assigned pos1 (regardless of name of the parameter)
  • second positional parameter is assigned pos2 (regardless of name of the parameter)

Attributes

aliases

Other names which can be used for this parameter. This is only useful for named parameters, and is typically used to declare short-form parameters. E.g. name --force, alias -f.

endOfNamed

After encountering this parameter, all subsequent command line arguments will be interpreted as positional, regardless if they start with a - or not.

flag

A parameter declared as a flag never takes an argument. This is only useful for named parameters.

name

The primary name of the parameter. This name can be used to look up arguments after calling GetOpt.parse.

positionalRepeats

If this parameter is positional, it will be repeated indefinitely.

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
case class Result(knownArgs: LinkedHashMap[String, ArrayBuffer[Arg]], unknown: Option[(String, Iterator[String])])

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def parse(params: Iterable[Param], args: Iterable[String]): Result
def parse(params: Iterable[Param], args: Iterator[String]): Result