Command.Spec, because the types are easier to understand.
basic ~summary ?readme spec main is a basic command that executes a function
which is passed parameters parsed from the command line according to
summary is to contain a short one-line description of its behavior.
readme is to
contain any longer description of its behavior that will go on that commands' help
Same general behavior as
basic, but takes a command line specification built up
Params instead of
group ~summary subcommand_alist is a compound command with named
subcommands, as found in
summary is to contain
a short one-line description of the command group.
readme is to
contain any longer description of its behavior that will go on that
command's help screen.
NOTE: subcommand names containing underscores will be rejected. Use dashes instead.
body is called when no additional arguments are passed -- in particular, when no
subcommand is passed. Its
path argument is the subcommand path by which the group
command was reached.
exec ~summary ~path_to_exe runs
exec on the executable at
`Absolute path then
path is executed without any further
qualification. If it is
`Relative_to_me path then
Sys.executable_name ^ "/" ^ path is executed instead. All of the usual caveats about
Sys.executable_name apply: specifically, it may only return an absolute path in
Linux. On other operating systems it will return
Care has been taken to support nesting multiple executables built with Command. In particular, recursive help and autocompletion should work as expected.
NOTE: non-Command executables can be used with this function but will still be
help -recursive is called or autocompletion is attempted (despite the
fact that neither will be particularly helpful in this case). This means that if you
have a shell script called "reboot-everything.sh" that takes no arguments and reboots
everything no matter how it is called, you shouldn't use it with
Additionally, no loop detection is attempted, so if you nest an executable within
help -recursive and autocompletion will hang forever (although actually
running the subcommand will work).
extract the summary string for a command
Run a command against
argv if it is specified.
extend can be used to add extra command line arguments to basic subcommands of the
extend will be passed the (fully expanded) path to a command, and its
output will be appended to the list of arguments being processed. For example,
suppose a program like this is compiled into
let bar = Command.basic ... let foo = Command.group ~summary:... ["bar", bar] let main = Command.group ~summary:... ["foo", foo] Command.run ~extend:(fun _ -> ["-baz"]) main
Then if a user ran
exe f b,
extend would be passed
["foo"; "bar"] and
would be appended to the command line for processing by
bar. This can be used to
add a default flags section to a user config file.
Deprecatedshould be used only by