Api

argparse.core.Api
trait Api extends TypesApi with ParsersApi with ReadersApi with VersionSpecificApi

Attributes

Graph
Supertypes
trait MacroApi
trait OutputApi
trait Printers
trait TypesApi
class Object
trait Matchable
class Any
Known subtypes
object default.type

Members list

Concise view

Type members

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)

Attributes

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
Graph
Supertypes
class Object
trait Matchable
class Any

Attributes

Inherited from:
ParsersApi
Graph
Supertypes
class Object
trait Matchable
class Any
object BooleanReader extends Reader[Boolean]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[Boolean]
class Object
trait Matchable
class Any
object DoubleReader extends Reader[Double]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[Double]
class Object
trait Matchable
class Any
object DurationReader extends Reader[Duration]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[Duration]
class Object
trait Matchable
class Any
object FilePathReader extends FsPathReader[FilePath]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait FsPathReader[FilePath]
trait Reader[FilePath]
class Object
trait Matchable
class Any
object FiniteDurationReader extends Reader[FiniteDuration]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[FiniteDuration]
class Object
trait Matchable
class Any
object FloatReader extends Reader[Float]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[Float]
class Object
trait Matchable
class Any
trait FsPathReader[A] extends Reader[A]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[A]
class Object
trait Matchable
class Any
Known subtypes
object FilePathReader.type
object JavaFileReader.type
object JavaPathReader.type
object PathReader.type
object RelPathReader.type
object SubPathReader.type
object InputStreamReader extends Reader[() => InputStream]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[() => InputStream]
class Object
trait Matchable
class Any
object InstantReader extends Reader[Instant]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[Instant]
class Object
trait Matchable
class Any
object JavaFileReader extends FsPathReader[File]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait FsPathReader[File]
trait Reader[File]
class Object
trait Matchable
class Any
object JavaPathReader extends FsPathReader[Path]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait FsPathReader[Path]
trait Reader[Path]
class Object
trait Matchable
class Any
object LocalDateReader extends Reader[LocalDate]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[LocalDate]
class Object
trait Matchable
class Any
object LocalDateTimeReader extends Reader[LocalDateTime]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[LocalDateTime]
class Object
trait Matchable
class Any
object LocalTime extends Reader[LocalTime]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[LocalTime]
class Object
trait Matchable
class Any
object OutputStreamReader extends Reader[() => OutputStream]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[() => OutputStream]
class Object
trait Matchable
class Any
object PathReader extends FsPathReader[Path]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait FsPathReader[Path]
trait Reader[Path]
class Object
trait Matchable
class Any
trait Printer[A]

Attributes

Inherited from:
OutputApi
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object RangeReader extends Reader[Range]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[Range]
class Object
trait Matchable
class Any
object ReadableReader extends Reader[Readable]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[Readable]
class Object
trait Matchable
class Any
object Reader

Attributes

Inherited from:
TypesApi
Graph
Supertypes
class Object
trait Matchable
class Any
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.

Attributes

Inherited from:
TypesApi
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object BooleanReader.type
object DoubleReader.type
object DurationReader.type
object FloatReader.type
trait FsPathReader[A]
object FilePathReader.type
object JavaFileReader.type
object JavaPathReader.type
object PathReader.type
object RelPathReader.type
object SubPathReader.type
object InputStreamReader.type
object InstantReader.type
object LocalDateReader.type
object LocalTime.type
object OutputStreamReader.type
object RangeReader.type
object ReadableReader.type
object RelPathReader extends FsPathReader[RelPath]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait FsPathReader[RelPath]
trait Reader[RelPath]
class Object
trait Matchable
class Any
object SubPathReader extends FsPathReader[SubPath]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait FsPathReader[SubPath]
trait Reader[SubPath]
class Object
trait Matchable
class Any
object ZonedDateTimeReader extends Reader[ZonedDateTime]

Attributes

Inherited from:
ReadersApi
Graph
Supertypes
trait Reader[ZonedDateTime]
class Object
trait Matchable
class Any
class command() extends StaticAnnotation

Attributes

Inherited from:
MacroApi
Graph
Supertypes
trait StaticAnnotation
class Annotation
class Object
trait Matchable
class Any
object given_Printer_Array extends Printer[Array[Byte]]

Attributes

Inherited from:
Printers
Graph
Supertypes
trait Printer[Array[Byte]]
class Object
trait Matchable
class Any
object given_Printer_Unit extends Printer[Unit]

Attributes

Inherited from:
Printers
Graph
Supertypes
trait Printer[Unit]
class Object
trait Matchable
class Any
object given_Printer_Writable extends Printer[Writable]

Attributes

Inherited from:
Printers
Graph
Supertypes
trait Printer[Writable]
class Object
trait Matchable
class Any
class unknownCommand() extends StaticAnnotation

Attributes

Inherited from:
MacroApi
Graph
Supertypes
trait StaticAnnotation
class Annotation
class Object
trait Matchable
class Any

Inherited types

type alias = alias

Attributes

Inherited from:
MacroApi
type env = env

Attributes

Inherited from:
MacroApi
type name = name

Attributes

Inherited from:
MacroApi

Value members

Inherited methods

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

Inherited from:
ParsersApi
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.

Attributes

Inherited from:
OutputApi

Inherited fields

val alias: alias.type

Attributes

Inherited from:
MacroApi
val env: env.type

Attributes

Inherited from:
MacroApi
val name: name.type

Attributes

Inherited from:
MacroApi
val pathCompleter: String => Seq[String]

Attributes

Inherited from:
ReadersApi

Givens

Inherited givens

given anyPrinter[A]: anyPrinter[A]

Attributes

Inherited from:
LowPrioPrinters

Attributes

Inherited from:
Printers
given given_Printer_Future[A](using p: Printer[A]): given_Printer_Future[A]

Attributes

Inherited from:
Printers
given given_Printer_Generator[A](using p: Printer[A]): given_Printer_Generator[A]

Attributes

Inherited from:
Printers

Attributes

Inherited from:
Printers

Attributes

Inherited from:
Printers
given nonProductListPrinter[A <: Iterable[B], B](using elemPrinter: Printer[B]): nonProductListPrinter[A, B]

Attributes

Inherited from:
Printers
inline given productListPrinter[A <: Iterable[B], B <: Product](using m: ProductLabels[B]): productListPrinter[A, B]

Attributes

Inherited from:
Printers

Implicits

Inherited implicits

implicit def CollectionReader[Elem, Col <: (Iterable)](implicit elementReader: Reader[Elem], factory: Factory[Elem, Col[Elem]]): Reader[Col[Elem]]

Attributes

Inherited from:
LowPrioReaders
implicit def FilePathCollectionReader[Col <: Iterable[FilePath]](implicit factory: Factory[FilePath, Col], pathReader: Reader[FilePath]): Reader[Col]

Attributes

Inherited from:
ReadersApi
implicit def IntegralReader[N](implicit numeric: Integral[N]): Reader[N]

Attributes

Inherited from:
ReadersApi
implicit def JFileCollectionReader[Col <: Iterable[File]](implicit factory: Factory[File, Col], pathReader: Reader[File]): Reader[Col]

Attributes

Inherited from:
ReadersApi
implicit def JPathCollectionReader[Col <: Iterable[Path]](implicit factory: Factory[Path, Col], pathReader: Reader[Path]): Reader[Col]

Attributes

Inherited from:
ReadersApi
implicit def Mapping[K, V](implicit kr: Reader[K], vr: Reader[V]): Reader[(K, V)]

Attributes

Inherited from:
ReadersApi
implicit def OptionReader[A](implicit elementReader: Reader[A]): Reader[Option[A]]

Attributes

Inherited from:
ReadersApi
implicit def PathCollectionReader[Col <: Iterable[Path]](implicit factory: Factory[Path, Col], pathReader: Reader[Path]): Reader[Col]

Attributes

Inherited from:
ReadersApi
implicit def RelPathCollectionReader[Col <: Iterable[RelPath]](implicit factory: Factory[RelPath, Col], pathReader: Reader[RelPath]): Reader[Col]

Attributes

Inherited from:
ReadersApi
implicit val StringReader: Reader[String]

Attributes

Inherited from:
TypesApi
implicit def SubPathCollectionReader[Col <: Iterable[SubPath]](implicit factory: Factory[SubPath, Col], pathReader: Reader[SubPath]): Reader[Col]

Attributes

Inherited from:
ReadersApi