clam.dispatch.Command
See theCommand companion object
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
When a command is called, it goes through two phases:
- argument parsing (this may alter the available subcommands)
- 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