Arg

com.phasmidsoftware.args.Arg
See theArg companion object
case class Arg[X](name: Option[String], value: Option[X]) extends Ordered[Arg[X]]

Case class to represent an "option" in a command line. Such an option has an (optional) name which is a String; and an (optional) value, which is of type X.

Type parameters

X

the underlying type of the value.

Value parameters

name

the optional name.

value

the optional value.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Ordered[Arg[X]]
trait Comparable[Arg[X]]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def as[Y : Derivable]: Arg[Y]

Convert this Arg[X] to an Arg[Y]. In practice, this method invokes mapMap with the function deriveFromOpt invoked on the Derivable[Y] evidence.

Convert this Arg[X] to an Arg[Y]. In practice, this method invokes mapMap with the function deriveFromOpt invoked on the Derivable[Y] evidence.

Type parameters

Y

the underlying type of the result, such that there is evidence of a Derivable[Y] provided implicitly.

Attributes

Returns

an Arg[Y].

def byName(w: String): Option[Arg[X]]

Method to get this Arg, if and only if its name matches the given String (w)

Method to get this Arg, if and only if its name matches the given String (w)

Value parameters

w

the string to match.

Attributes

Returns

either Some(this) or else None.

def compare(that: Arg[X]): Int

Method to compare this Arg with that.

Method to compare this Arg with that.

This is a total order: two named Args (options) compare by name (their values are intentionally not significant, since ordering exists only to match Args against a Synopsis); an unnamed Arg (operand) always sorts after a named one, matching the POSIX convention that options precede operands; two unnamed Args compare equal.

Value parameters

that

the Arg to compare with.

Attributes

Returns

the result of invoking x compare y where x and y are the names of this and that Args.

def eitherOr[Y : Derivable]: Arg[Either[X, Y]]

Convert this Arg[X] to an Arg of Either[Y]. In practice, this method invokes map with the function deriveFromOpt invoked on the Derivable[Y] evidence.

Convert this Arg[X] to an Arg of Either[Y]. In practice, this method invokes map with the function deriveFromOpt invoked on the Derivable[Y] evidence.

Type parameters

Y

the underlying type of the result, such that there is evidence of a Derivable[Y] provided implicitly.

Attributes

Returns

an Arg of Either[Y]..

def flatMap[Y](f: X => Arg[Y]): Arg[Y]

Method to flatMap this Arg into an Arg of underlying type Y

Method to flatMap this Arg into an Arg of underlying type Y

Type parameters

Y

the underlying type of the result.

Value parameters

f

a function to convert an X into a Y.

Attributes

Returns

an Arg[Y]

def hasValue: Boolean

Method to determine if this Arg has a value, thus either an option with value, or an operand.

Method to determine if this Arg has a value, thus either an option with value, or an operand.

Attributes

Returns

true if value is not None

def isOption: Boolean

Method to determine if this Arg is an option (also known as a "flag"), as opposed to an operand.

Method to determine if this Arg is an option (also known as a "flag"), as opposed to an operand.

Attributes

Returns

true if name is not None

Method to determine if this Arg is optional according to the synopsis provided.

Method to determine if this Arg is optional according to the synopsis provided.

Value parameters

s

the synopsis.

Attributes

Returns

Kleenean(true if this Arg is optional.

def map[Y](f: X => Y): Arg[Y]

Method to map this Arg into an Arg of underlying type Y

Method to map this Arg into an Arg of underlying type Y

Type parameters

Y

the underlying type of the result.

Value parameters

f

a function to convert an X into a Y.

Attributes

Returns

an Arg[Y]

def mapMap[Y](f: X => Option[Y]): Arg[Y]

Method to map this Arg into an Arg of underlying type Y but where the function given is X => Option[Y]

Method to map this Arg into an Arg of underlying type Y but where the function given is X => Option[Y]

Type parameters

Y

the underlying type of the result.

Value parameters

f

a function to convert an X into an Option[Y].

Attributes

Returns

an Arg[Y]

def process(fm: Map[String, (Option[X]) => Unit]): Try[Option[X]]

Method to process this Arg, given a map of options and their corresponding functions.

Method to process this Arg, given a map of options and their corresponding functions.

Value parameters

fm

a Map of String->function where function is of type Option[X]=>Unit

Attributes

Returns

a Success[None] if there was a function defined for this Arg in the map fm AND if the function invocation was successful; otherwise a Failure[X]

override def toString: String

Method to form a String from this Arg

Method to form a String from this Arg

Attributes

Returns

"Arg: flag name/anonymous with value: value/none"

Definition Classes
Any
def toY[Y : Derivable]: Try[Y]

Method to get the value of this Arg as a Y.

Method to get the value of this Arg as a Y.

Type parameters

Y

the type of the result.

Attributes

Returns

the result of deriving a Y value from the actual value of this Arg, wrapped in Try.

Inherited methods

def <(that: Arg[X]): Boolean

Attributes

Inherited from:
Ordered
def <=(that: Arg[X]): Boolean

Attributes

Inherited from:
Ordered
def >(that: Arg[X]): Boolean

Attributes

Inherited from:
Ordered
def >=(that: Arg[X]): Boolean

Attributes

Inherited from:
Ordered
def compareTo(that: Arg[X]): Int

Attributes

Inherited from:
Ordered
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Concrete fields

lazy val asOption: Option[(String, Option[X])]

Method to return this Arg as an optional tuple of a String and an optional X value, according to whether it's an "option".

Method to return this Arg as an optional tuple of a String and an optional X value, according to whether it's an "option".

Attributes

Returns

Some[(String, Option[X]) if name is not None otherwise None.

lazy val operand: Option[X]

Method to return this Arg as an optional X value, according to whether it's an "operand".

Method to return this Arg as an optional X value, according to whether it's an "operand".

Attributes

Returns

Some[X] if name is None otherwise None.