Module type Command_intf.Command
module Arg_type : sig ... end
Argument types.
module Flag : sig ... end
Command-line flag specifications.
module Anons : sig ... end
Anonymous command-line argument specification.
module Param : sig ... end
Command-line parameter specification.
module Let_syntax : sig ... end with type 'a t := 'a Param.t
module Spec : sig ... end
The old interface for command-line specifications -- Do Not Use.
type ('main, 'result) basic_spec_command
= summary:Core_kernel__.Import.string -> ?readme:(Core_kernel__.Import.unit -> Core_kernel__.Import.string) -> ('main, Core_kernel__.Import.unit -> 'result) Spec.t -> 'main -> t
val basic_spec : ('main, Core_kernel__.Import.unit) basic_spec_command
basic_spec ~summary ?readme spec main
is a basic command that executes a functionmain
which is passed parameters parsed from the command line according tospec
.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 command's help screen.
type 'result basic_command
= summary:Core_kernel__.Import.string -> ?readme:(Core_kernel__.Import.unit -> Core_kernel__.Import.string) -> (Core_kernel__.Import.unit -> 'result) Param.t -> t
val basic : Core_kernel__.Import.unit basic_command
Same general behavior as
basic_spec
, but takes a command line specification built up usingParams
instead ofSpec
.
val group : summary:Core_kernel__.Import.string -> ?readme:(Core_kernel__.Import.unit -> Core_kernel__.Import.string) -> ?preserve_subcommand_order:Core_kernel__.Import.unit -> ?body:(path:Core_kernel__.Import.string Core_kernel__.Import.list -> Core_kernel__.Import.unit) -> (Core_kernel__.Import.string * t) Core_kernel__.Import.list -> t
group ~summary subcommand_alist
is a compound command with named subcommands, as found insubcommand_alist
.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. Itspath
argument is the subcommand path by which the group command was reached.
val lazy_group : summary:Core_kernel__.Import.string -> ?readme:(Core_kernel__.Import.unit -> Core_kernel__.Import.string) -> ?preserve_subcommand_order:Core_kernel__.Import.unit -> ?body:(path:Core_kernel__.Import.string Core_kernel__.Import.list -> Core_kernel__.Import.unit) -> (Core_kernel__.Import.string * t) Core_kernel__.Import.list Core_kernel.Lazy.t -> t
lazy_group
is the same asgroup
, except that the list of subcommands may be generated lazily.
val exec : summary:Core_kernel__.Import.string -> ?readme:(Core_kernel__.Import.unit -> Core_kernel__.Import.string) -> ?child_subcommand:Core_kernel__.Import.string Core_kernel__.Import.list -> path_to_exe:[ `Absolute of Core_kernel__.Import.string | `Relative_to_argv0 of Core_kernel__.Import.string | `Relative_to_me of Core_kernel__.Import.string ] -> Core_kernel__.Import.unit -> t
exec ~summary ~path_to_exe
runsexec
on the executable atpath_to_exe
. Ifpath_to_exe
is`Absolute path
thenpath
is executed without any further qualification. If it is`Relative_to_me path
thenFilename.dirname Sys.executable_name ^ "/" ^ path
is executed instead. All of the usual caveats aboutSys.executable_name
apply: specifically, it may only return an absolute path in Linux. On other operating systems it will returnSys.argv.(0)
. If it is`Relative_to_argv0 path
thenSys.argv.(0) ^ "/" ^ path
is executed.The
child_subcommand
argument allows referencing a subcommand one or more levels below the top-level of the child executable. It should not be used to pass flags or anonymous arguments to the child.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 executed when
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 withexec
.Additionally, no loop detection is attempted, so if you nest an executable within itself,
help -recursive
and autocompletion will hang forever (although actually running the subcommand will work).
val of_lazy : t Core_kernel.Lazy.t -> t
of_lazy thunk
constructs a lazy command that is forced only when necessary to run it or extract its shape.
val summary : t -> Core_kernel__.Import.string
Extracts the summary string for a command.
module Shape : sig ... end
val exit : Core_kernel__.Import.int -> _
call this instead of
Core.exit
if in command-related code that you want to run in tests. For example, in the body ofCommand.Param.no_arg_abort
module Deprecated : sig ... end
Deprecated
should be used only byDeprecated_command
. At some point it will go away.