Up

Module Deprecated_command = Deprecated_command

Signature

command-line parsing with hierarchical sub-commands

exception Invalid_arguments of string list
module Flag : sig .. end
module Shared_flags : sig .. end
type t
module Autocomplete : sig .. end

create ~autocomplete ~summary ~usage_arg ~init ~flags ~final main constructs a base command from the following data:

  • 'accum a mutable accumulator type for gathering arguments
  • 'args a composite argument type for the command, build from 'accum
  • autocomplete an optional argument defining a bash autocompletion function for the base command.
  • summary a short description of what the command does
  • readme a longer description of what the command does
  • usage_arg an abbreviation of the arguments it expects
  • init a function that creates an mutable accumulator of type 'accum
  • flags a list of command line flags together with their associated accumulator-mutating actions
  • final a function that constructs the final argument structure of type 'args from the accumulated arguments. The second argument to the function is the list of all annonymous arguments. This function should raise an exception with some explanation if it is unable to construct a complete value of type 'args.
  • help an optional function that will be called to generate help for a command instead of the standard help
  • main the main function, parameterized by the argument structure
val create : ?autocomplete:Autocomplete.t -> ?readme:(unit -> string) -> summary:string -> usage_arg:string -> init:(unit -> 'accum) -> flags:'accum Flag.t list -> final:('accum -> string list -> 'argv) -> ('argv -> unit) -> t
val create0 : ?autocomplete:Autocomplete.t -> ?readme:(unit -> string) -> summary:string -> usage_arg:string -> init:(unit -> 'accum) -> flags:'accum Flag.t list -> final:('accum -> 'args) -> ('args -> unit) -> t
val create_no_accum : ?autocomplete:Autocomplete.t -> ?readme:(unit -> string) -> summary:string -> usage_arg:string -> flags:unit Flag.t list -> final:(string list -> 'args) -> ('args -> unit) -> t
val create_no_accum0 : ?autocomplete:Autocomplete.t -> ?readme:(unit -> string) -> summary:string -> usage_arg:string -> flags:unit Flag.t list -> (unit -> unit) -> t
val group : summary:string -> ?readme:(unit -> string) -> (string * t) list -> t

group ~summary [...; (name_i, t_i); ...] is an aggregate command that dispatches to one of the named sub-commands. A "help" sub-command will also be generated for the group.

The name cannot contain underscores, however passing allow_underscores=true into run will parse underscores as dashes on the command line.

type 'a with_run_flags = ?version:string -> ?build_info:string -> ?argv:string list -> ?allow_unknown_flags:bool -> ?allow_underscores:bool -> ?hash_bang_expand:bool -> ?post_parse:([
| `Ok
| `Error
| `Help
] -> string list -> unit) -> t -> 'a
val run : unit with_run_flags
val get_expanded_argv : unit -> string list
val get_expanded_cmdline : unit -> string
module Version : sig .. end
module Annotated_field : sig .. end
This module is intended to help in using pa_fields to easily generate Command.t's when you have a record type each field of which you would like specified as a command line argument.
module Flags_ext : sig .. end
module Helpers : sig .. end
val of_core_command : Core.Std.Command.t -> t