package core_unix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
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.

module Path : sig ... end
module Shape : sig ... end

Exposes the shape of a command.

module Deprecated : sig ... end

Deprecated should be used only by Deprecated_command. At some point it will go away.

OCaml

Innovation. Community. Security.