package core_unix
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=486d0e954603960fa081b3fd23e3cc3e50ac0892544acd35f9c2919c4bf5f67b
doc/core_unix.command_unix/Command_unix/index.html
Module Command_unixSource
val run :
?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 ->
unitRuns 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"]) mainThen 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.