FirstOfByArgIndex

oxygen.cli.Params.FirstOfByArgIndex
final case class FirstOfByArgIndex[A](options: NonEmptyList[Params[A]]) extends Params[A]

Will take all parsers specified, each attempting to parse the remaining arguments. If none succeed, will return the errors from all parsers. If only one succeeds, will return the success of that parser. If multiple succeed, will return the first success order wise.

Multi example: --key-1=value-1 --key-2=value-2 Both succeed with Key1("value-1") and Key2("value-2"). Key1("value-1") would be the success that is returned.

This is useful when you want to be able to parse an ADT, and have the results come back in a fixed order. In the above example, if you had 2 separate list parsers for key-1 and key-2, you would not know what order they were parsed in. But, if you combined them into an ADT, used Params.firstOf, and Params.repeated, then you would be able to know what order things were parsed in:

  • --key-1=value-1 --key-2=value-2 -> List(Key1("value-1"), Key2("value-2"))
  • --key-2=value-2 --key-1=value-1 -> List(Key2("value-2"), Key1("value-1"))

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Params[A]
trait Parser[A]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def buildInternal(usedParams: Set[SimpleName]): Either[BuildError, (Set[SimpleName], Params[A])]

This should do 2 things:

This should do 2 things:

  1. Fail if there are duplicate param names
  2. Convert Defaultable.Auto into Defaultable.Some/Defaultable.None based on start of long name

Attributes

Definition Classes
override def helpMessage: ParamMessage

Attributes

Definition Classes
override def map[B](f: A => B): Params[B]

Attributes

Definition Classes
override def mapOrFail[B](f: A => Either[String, B]): Params[B]

Attributes

Definition Classes
override def optionalName: Option[Name]

Attributes

Definition Classes
override def parseParams(params: List[ParamLike]): ParseResult[A]

Attributes

Definition Classes

Inherited methods

final def &&[B](that: Params[B])(implicit zip: Zip[A, B]): Params[zip.Out]

Attributes

See also
Inherited from:
Params
final def <||[A2 >: A](that: Params[A2]): Params[A2]

Attributes

See also
Inherited from:
Params
final def <||[A2 >: A](that: Parser[A2]): Parser[A2]

Attributes

Inherited from:
Parser
final def <||>[B](that: Params[B]): Params[Either[A, B]]

Attributes

See also
Inherited from:
Params
final def <||>[B](that: Parser[B]): Parser[Either[A, B]]

Attributes

Inherited from:
Parser
final def ^>>[B](that: Parser[B])(implicit zip: Zip[A, B]): Parser[zip.Out]

Attributes

Inherited from:
Parser
final def apply(args: String*): FinalParseResult[A]

Attributes

Inherited from:
Parser
final def apply(args: List[String]): FinalParseResult[A]

Attributes

Inherited from:
Parser
final def bracketed(name: LongName): Values[A]

Attributes

Inherited from:
Parser
final def build: Either[BuildError, Parser[Either[HelpType, A]]]

Attributes

Inherited from:
Parser
final def optional: Params[Option[A]]

Attributes

Inherited from:
Params
final override def parse(values: List[ValueLike], params: List[ParamLike]): ParseResult[A]

Attributes

Definition Classes
Inherited from:
Params
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
final def repeated: Params[List[A]]

Attributes

Inherited from:
Params
final def repeatedNel: Params[NonEmptyList[A]]

Attributes

Inherited from:
Params
final def withDefault[A2 >: A](default: A2): Params[A2]

Attributes

Inherited from:
Params
final def withOptionalDefault[A2 >: A](default: Option[A2]): Params[A2]

Attributes

Inherited from:
Params
final def ||[A2 >: A](that: Params[A2]): Params[A2]

Attributes

See also
Inherited from:
Params