OutputApi

trait OutputApi extends ParsersApi with TypesApi with Printers
Companion
object
trait Printers
trait TypesApi
class Object
trait Matchable
class Any
trait MacroApi
trait Api
object default

Type members

Classlikes

trait Printer[A]

Inherited classlikes

class ArgumentParser(val description: String, val helpFlags: Seq[String], val bashCompletionFlags: Seq[String])

A simple command line argument parser.

A simple command line argument parser.

Usage:

  1. Define parameters with param, requiredParam and repeatedParam. Each of these methods gives back a handle to a future argument value.

  2. Call parseOrExit() with actual arguments.

  3. If parsing succeeds, the arguments will be available in the handles defined in step 1.

If parsing fails, error descriptions are printed and the program exits with 2.

Example:

val parser = argparse.default.ArgumentParser()

val p1 = parser.param[String]("--this-is-a-named-param", default = "default value")
val p2 = parser.param[Int]("positional-param", default = 2)

parser.parseOrExit(Seq("--this-is-a-named-param=other", 5))
println(p1.value)
println(p2.value)
Value Params
bashCompletionFlag

Use these flags to print a sourceable bash-completion script. Set to empty to disable.

description

A short description of this command. Used in help messages.

helpFlags

Use these flags to print the help message. Set to empty to disable.

Inherited from
ParsersApi
Inherited from
ParsersApi
object Reader
Inherited from
TypesApi
@implicitNotFound("No Reader[${A}] found. A reader is required to parse a command line argument from a string to a ${A}. ".+("Please define a Reader[${A}]."))
trait Reader[A]

A typeclass that defines how to convert a string from a single command line argument to a given type.

A typeclass that defines how to convert a string from a single command line argument to a given type.

Inherited from
TypesApi

Value members

Concrete methods

def handleError(t: Throwable): Nothing

Top-level error handler for command line applications using the annotation API.

Top-level error handler for command line applications using the annotation API.

You can override this to change what should be done on errors.

The default implementation prints the exception's message unless the DEBUG environment variable is set, in which case the whole stack trace is printed. Then, it exits with error code 1.

Inherited methods

def defaultBashCompletionFlags: Seq[String]

The name of the flag to use for generating standalone bash-completion.

The name of the flag to use for generating standalone bash-completion.

Set this to empty to disable bash-completion entirely.

Note that individual argument parsers may override this.

Inherited from
ParsersApi
def defaultHelpFlags: Seq[String]

The name of the flag to use for printing help messages.

The name of the flag to use for printing help messages.

Set this to empty to disable help entirely.

Note that individual argument parsers may override this.

Inherited from
ParsersApi
def defaultHelpMessage(parser: ArgumentParser): String

Generate a help message from parameters.

Generate a help message from parameters.

This message will be used by ArgumentParsers. Overriding this allows you to customize the help message of all ArgumentParsers.

Inherited from
ParsersApi
protected def exit(code: Int): Nothing

Called by parseOrExit in case of error.

Called by parseOrExit in case of error.

Overriding this can be useful in situations where you do not want to exit, for example in tests.

Inherited from
ParsersApi

Givens

Inherited givens

given given_Printer_A[A]: Printer[A]
Inherited from
LowPrioPrinters
given given_Printer_Array: Printer[Array[Byte]]
Inherited from
Printers
given given_Printer_Future[A](using val p: Printer[A]): Printer[Future[A]]
Inherited from
Printers
given given_Printer_Generator[A](using val p: Printer[A]): Printer[Generator[A]]
Inherited from
Printers
Inherited from
Printers
Inherited from
Printers
given nonProductListPrinter[A <: Iterable[B], B](using val elemPrinter: Printer[B]): Printer[A]
Inherited from
Printers
inline given productListPrinter[A <: Iterable[B], B <: Product](using val m: ProductLabels[B]): Printer[A]
Inherited from
Printers

Implicits

Inherited implicits

implicit val StringReader: Reader[String]
Inherited from
TypesApi