Legend:
Library
Module
Module type
Parameter
Class
Class type
Commands.
Command line syntaxes are implicitely defined by Terms. A command value binds a syntax and its documentation to a command name.
A command can group a list of sub commands (and recursively). In this case your tool defines a tree of commands, each with its own command line syntax. The root of that tree is called the main command; it represents your tool and its name.
Command information
Command information defines the name and documentation of a command.
val info :
?deprecated:string ->?man_xrefs:Manpage.xref list->?man:Manpage.block list->?envs:Env.info list->?exits:Exit.info list->?sdocs:string ->?docs:string ->?doc:string ->?version:string ->string ->info
info ?sdocs ?man ?docs ?doc ?version name is a term information such that:
name is the name of the command.
version is the version string of the command line tool, this is only relevant for the main command and ignored otherwise.
deprecated, if specified the command is deprecated and the string is a message output on standard error when the command is used.
doc is a one line description of the command used for the NAME section of the command's man page and in command group listings.
docs, for commands that are part of a group, the title of the section of the parent's command man page where it should be listed (defaults to Manpage.s_commands).
sdocs defines the title of the section in which the standard --help and --version arguments are listed (defaults to Manpage.s_common_options).
exits is a list of exit statuses that the command evaluation may produce, defaults to Exit.defaults.
envs is a list of environment variables that influence the command's evaluation.
man is the text of the man page for the command.
man_xrefs are cross-references to other manual pages. These are used to generate a Manpage.s_see_also section.
doc, man, envs support the documentation markup language in which the following variables are recognized:
$(tname) the (term's) command's name.
$(mname) the main command name.
$(iname) the command invocation from main command to the command name.
Commands
type'a t
The type for commands whose evaluation result in a value of type 'a.
v i t is a command with information i and command line syntax parsed by t.
val group : ?default:'aTerm.t->info->'at list->'at
group i ?default cmds is a command with information i that groups sub commands cmds. default is the command line syntax to parse if no sub command is specified on the command line. If default is None (default), the tool errors when no sub command is specified.
eval_value' is like eval_value, but if the command term does not evaluate, returns an exit code like the evaluation function do (which can be Exit.ok in case help or version was requested).
eval_peek_opts version_opt argv t evaluates t, a term made of optional arguments only, with the command line argv (defaults to Sys.argv). In this evaluation, unknown optional arguments and positional arguments are ignored.
The evaluation returns a pair. The first component is the result of parsing the command line argv stripped from any help and version option if version_opt is true (defaults to false). It results in:
Some _ if the command line would be parsed correctly given the partial knowledge in t.
None if a parse error would occur on the options of t
The second component is the result of parsing the command line argv without stripping the help and version options. It indicates what the evaluation would result in on argv given the partial knowledge in t (for example it would return `Help if there's a help option in argv). However in contrasts to eval_value no side effects like error reporting or help output occurs.
Note. Positional arguments can't be peeked without the full specification of the command line: we can't tell apart a positional argument from the value of an unknown optional argument.