std/cli/input
std/cli/src/input.trb
Input: what a command line said, as a handler reads it.
type Input
type Input
The values of one command line, read by the handler of the command it chose. Everything a command declares is
here: a flag that was left out is false, an option that was left out has its default, and the arguments are the
rest of the line. Reading a name the command did not declare is a mistake of the program and panics.
Command.parse makes one; a test can make one the same way.
field path
path: List<String>
The command that was chosen, from the program's own name down: ["torb", "check"].
field flagValues
flagValues: Map<String, Bool>
Every flag of the chosen command and of the commands above it, by name, without dashes.
field optionValues
optionValues: Map<String, String>
The text of every option, by name, without dashes: what the line said, or the default.
field argumentValues
argumentValues: Map<String, List<String>>
The positional arguments, by the name that arguments gave them.
field optionalValues
optionalValues: Map<String, List<String>>
The values of the options optional declared, by name: the one value the line gave, or none.
field repeatedValues
repeatedValues: Map<String, List<String>>
The values of the options repeatable declared, by name, in the order of the line.
fn flag
fn flag(name: String): Bool
Whether the line had --name.
Panics
When the command did not declare a flag name, with the command <path> declares no flag '<name>': a mistake of
the program, not of the line.
fn option
fn option<T: Argument>(name: String): T
The value of --name, read as a T: the line's, or else the default.
Panics
When the command did not declare an option name, with the command <path> declares no option '<name>', and when
the option is declared with another type than T, with option '<name>' is declared with another type than it is read as: both are mistakes of the program, not of the line.
fn optional
fn optional<T: Argument>(name: String): T?
The value of --name, which optional declared, read as a T: None where the line left it out. The last one
wins where the line gave it more than once.
Panics
When the command did not declare an optional option name, with the command <path> declares no optional option '<name>', and when the option is declared with another type than T, with option '<name>' is declared with another type than it is read as: both are mistakes of the program, not of the line.
fn repeated
fn repeated<T: Argument>(name: String): List<T>
Every value of --name, which repeatable declared, read as a T, in the order of the line; the empty list
where the line left it out.
Panics
When the command did not declare a repeatable option name, with the command <path> declares no repeatable option '<name>', and when the option is declared with another type than T, with option '<name>' is declared with another type than it is read as: both are mistakes of the program, not of the line.
fn arguments
fn arguments(name: String): List<String>
The positional arguments that arguments(name) collects, in the order of the line.
Panics
When the command did not declare arguments name, with the command <path> declares no arguments '<name>': a
mistake of the program, not of the line.