package core_unix
Install
Dune Dependency
Authors
Maintainers
Sources
md5=9370dca36f518fcea046d2752e3de22b
sha512=c4e8ce9d5885ac8fa8d554a97e1857f3a1c933e0eb5dfd4fe874412b9d09e6d0a2973b644733855553f33f5c859719228f0e6aaf3a2b7eb5befb46fc513750de
doc/core_unix.command_unix/Command_unix/index.html
Module Command_unix
Source
val run :
?add_validate_parsing_flag:bool ->
?verbose_on_parse_error:bool ->
?version:string ->
?build_info:string ->
?argv:string list ->
?extend:(string list -> string list) ->
?when_parsing_succeeds:(unit -> unit) ->
?complete_subcommands:
(path:string list -> part:string -> string list list -> string list option) ->
Core.Command.t ->
unit
Runs a command against Sys.argv
, or argv
if it is specified.
extend
can be used to add extra command line arguments to basic subcommands of the command. 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 exe
:
let bar = Command.basic ___
let foo = Command.group ~summary:___ ["bar", bar]
let main = Command.group ~summary:___ ["foo", foo]
let () = Command.run ~extend:(fun _ -> ["-baz"]) main
Then if a user ran exe f b
, extend
would be passed ["foo"; "bar"]
and "-baz"
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.
verbose_on_parse_error
controls whether to print a line suggesting the user try the "-help" flag when an exception is raised while parsing the arguments. By default it is true.
when_parsing_succeeds
is invoked after argument parsing has completed successfully, but before the main function of the associated command has run. One use-case is for performing logging when a command is being invoked, where there's no reason to log incorrect invocations or -help calls.
complete_subcommands
can be used to override the completion mechanism.
Exposes the shape of a command.
Deprecated
should be used only by Deprecated_command
. At some point it will go away.