Cmdliner.Term
Terms.
A term made of terms referring to command line arguments implicitly defines a command line syntax fragment. Terms are associated to command values Cmd.t
which are evaluated to eventually produce an exit code.
Nowadays terms are best defined using the Cmdliner.Term.Syntax
. See examples in the blueprints.
val const : 'a -> 'a t
const v
is a term that evaluates to v
.
app f v
is a term that evaluates to the result applying the evaluation of v
to the one of f
.
module Syntax : sig ... end
let
operators.
Cmd.t
evaluationThese special terms allow to interact with the low-level evaluation process performed on commands.
term_result
is such that:
term_result ~usage (Ok v)
evaluates to Ok (`Ok v)
.term_result ~usage (Error (`Msg e))
evaluates to Error `Term
with the error message e
and usage shown according to usage
(defaults to false
)See also term_result'
.
term_result'
is like term_result
but with a string
error case.
cli_parse_result
is such that:
cli_parse_result (Ok v)
evaluates Ok (`Ok v)).} {- [cli_parse_result (Error (`Msg e))]
evaluates Error `Parse
.See also cli_parse_result'
.
cli_parse_result'
is like cli_parse_result
but with a string
error case.
val main_name : string t
main_name
is a term that evaluates to the main command name; that is the name of the tool.
val choice_names : string list t
choice_names
is a term that evaluates to the names of the commands that are children of the main command.
with_used_args t
is a term that evaluates to t
tupled with the arguments from the command line that where used to evaluate t
.
The type for command return values. See ret
.
ret v
is a term whose evaluation depends on the case to which v
evaluates. With :
`Ok v
, it evaluates to v
.`Error (usage, e)
, the evaluation fails and Cmdliner
prints the error e
and the term's usage if usage
is true
.`Help (format, name)
, the evaluation fails and Cmdliner
prints a manpage in format format
. If name
is None
this is the the main command's manpage. If name
is Some c
this is the man page of the sub command c
of the main command.