clam.dispatch

Members list

Concise view

Type members

Classlikes

class Command(val name: String, val description: String, val pdefs: ArrayBuffer[ParamDef], var parse: (Command, Context, Result) => Result[Any], var action: Option[Any => Result[Any]], val builtins: Map[String, Command], var listExternalCommands: () => Iterable[String], var callExternalCommand: Option[(Context, Iterator[String]) => String => Result[Any]], var makeHelp: (Command, Context) => String) extends (Context, Iterator[String]) => Result[Any]

An entrypoint to the application

An entrypoint to the application

When a command is called, it goes through two phases:

  1. argument parsing (this may alter the available subcommands)
  2. running an action or subcommand

A command can be in a tree, but it is designed to be callable as a top-level entrypoint. As such, parent args must be stored in a global context, usually the environment.

When a command is called, it will first parse arguments depending on its parameter definitions. Then, depending on the remainder, a subcommand may be called.

Attributes

action

A function to call with the extracted result

builtins

Subcommand candidates to call

extract

A function that is called with the command's arguments, and whose result may be passed to an action if one is defined. The arguments are: (context, result, next), where:

  • context: the global (mutable) context. Values may be passed to subcommands by putting them in this context
  • result: the getopt parameter result from the pdefs
  • next: whether or not a subcommand will be called
pdefs

The parameter definitions

Companion:
object
Graph
Supertypes
trait (Context, Iterator[String]) => Result[Any]
class Object
trait Matchable
class Any
object Command

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Command.type
case class Context(stdout: PrintStream, stderr: PrintStream, env: Map[String, String], terminal: Terminal)

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
case class ParamDef(names: Seq[String], description: String, argName: Option[String], repeats: Boolean, endOfNamed: Boolean, interactiveCompleter: String => Iterable[String], standaloneCompleter: BashCompleter)

A CLI parameter definition.

A CLI parameter definition.

Includes properties for parsing as well as for auxiliary utilities such as help messages and completion.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
enum Result[+A]

Attributes

Graph
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Known subtypes