package cmdliner
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=2ca8c9a2b392e031f88aa0e76f2ab50c8e9e28d77852d04ca2d5b62326630ca41567ce0832e9a9334d9b130b48deede66c7880a9d0aee75a1afe7541097e249f
doc/cmdliner/Cmdliner/Term/index.html
Module Cmdliner.TermSource
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.
Terms
val const : 'a -> 'a tconst 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 ... endlet operators.
Interacting with Cmd.t evaluation
These 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 toOk (`Ok v).term_result ~usage (Error (`Msg e))evaluates toError `Termwith the error messageeand usage shown according tousage(defaults tofalse)
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)evaluatesOk (`Ok v)).} {- [cli_parse_result (Error (`Msg e))]evaluatesError `Parse.
See also cli_parse_result'.
cli_parse_result' is like cli_parse_result but with a string error case.
val main_name : string tmain_name is a term that evaluates to the main command name; that is the name of the tool.
val choice_names : string list tchoice_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 tov.`Error (usage, e), the evaluation fails andCmdlinerprints the erroreand the term's usage ifusageistrue.`Help (format, name), the evaluation fails andCmdlinerprints a manpage in formatformat. IfnameisNonethis is the the main command's manpage. IfnameisSome cthis is the man page of the subcommandcof the main command.
val env : (string -> string option) tenv is the env argument given to command evaluation functions. If you need to refine the environment lookup done by Cmdliner's machinery you should use this rather than direct calls to Sys.getenv_opt.