module type S = sig ... end
include S
Command.Param
is intended to be used with the [%map_open]
syntax defined in ppx_let
, like so:
Various internal values
val help : Base.String.t Lazy.t t
The help text for the command.
val path : Base.String.t Base.List.t t
The subcommand path of the command.
val args : Base.String.t Base.List.t t
The arguments passed to the command.
val flag : ?aliases:Base.String.t Base.List.t -> ?full_flag_required:Base.Unit.t -> Base.String.t -> 'a Flag.t -> doc:Base.String.t -> 'a t
flag name spec ~doc
specifies a command that, among other things, takes a flag namedname
on its command line.doc
indicates the meaning of the flag.All flags must have a dash at the beginning of the name. If
name
is not prefixed by "-", it will be normalized to"-" ^ name
.Unless
full_flag_required
is used, one doesn't have to passname
exactly on the command line, but only an unambiguous prefix ofname
(i.e., a prefix which is not a prefix of any other flag's name).NOTE: the
doc
for a flag which takes an argument should be of the formarg_name ^ " " ^ description
wherearg_name
describes the argument anddescription
describes the meaning of the flag.NOTE: flag names (including aliases) containing underscores will be rejected. Use dashes instead.
NOTE: "-" by itself is an invalid flag name and will be rejected.
val flag_optional_with_default_doc : ?aliases:Base.String.t Base.List.t -> ?full_flag_required:Base.Unit.t -> Base.String.t -> 'a Arg_type.t -> ('a -> Sexp.t) -> default:'a -> doc:Base.String.t -> 'a t
flag_optional_with_default_doc name arg_type sexp_of_default ~default ~doc
is a shortcut forflag
, where:- The
Flag.t
isoptional_with_default default arg_type
- The
doc
is passed through with an explanation of what the default value appended.
- The
val anon : 'a Anons.t -> 'a t
anon spec
specifies a command that, among other things, takes the anonymous arguments specified byspec
.
module If_nothing_chosen : sig ... end
val choose_one : 'a Base.Option.t t Base.List.t -> if_nothing_chosen:('a, 'b) If_nothing_chosen.t -> 'b t
choose_one clauses ~if_nothing_chosen
expresses a sum type. It raises if more than one ofclauses
isSome _
. Whenif_nothing_chosen = `Raise
, it also raises if none ofclauses
isSome _
.
val and_arg_names : 'a t -> ('a * Base.String.t Base.List.t) t
and_arg_names t
returns both the value oft
and the names of the arguments that went intot
. Useful for errors that reference multiple params.
val and_arg_name : 'a t -> ('a * Base.String.t) t
Like
and_arg_names
, but asserts that there is exactly one name.
module Arg_type : module type of Arg_type with type 'a t = 'a Arg_type.t
include module type of Arg_type.Export
val string : Base.String.t Arg_type.t
val int : Base.Int.t Arg_type.t
Beware that an anonymous argument of type
int
cannot be specified as negative, as it is ambiguous whether -1 is a negative number or a flag. (The same applies tofloat
,time_span
, etc.) You can use the special built-in "-anon" flag to force a string starting with a hyphen to be interpreted as an anonymous argument rather than as a flag, or you can just make it a parameter to a flag to avoid the issue.
val char : Base.Char.t Arg_type.t
val float : Base.Float.t Arg_type.t
val bool : Base.Bool.t Arg_type.t
val date : Date.t Arg_type.t
val percent : Percent.t Arg_type.t
val host_and_port : Host_and_port.t Arg_type.t
val sexp : Sexp.t Arg_type.t
val sexp_conv : (Sexp.t -> 'a) -> 'a Arg_type.t
include module type of Flag with type 'a t := 'a Flag.t
val required : 'a Arg_type.t -> 'a Flag.t
Required flags must be passed exactly once.
val optional : 'a Arg_type.t -> 'a Flag.t
Optional flags may be passed at most once.
val optional_with_default : 'a -> 'a Arg_type.t -> 'a Flag.t
optional_with_default
flags may be passed at most once, and default to a given value.
val listed : 'a Arg_type.t -> 'a Flag.t
listed
flags may be passed zero or more times.
val one_or_more : 'a Arg_type.t -> 'a Flag.t
one_or_more
flags must be passed one or more times.
val no_arg : 'a Flag.t
no_arg
flags may be passed at most once. The boolean returned is true iff the flag is passed on the command line.
val no_arg_register : key:'a Univ_map.With_default.Key.t -> value:'a -> 'a Flag.t
no_arg_register ~key ~value
is likeno_arg
, but associatesvalue
withkey
in the autocomplete environment.
val no_arg_some : 'a -> 'a Flag.t
no_arg_some value
is likeno_arg
, but will returnSome value
if the flag is passed on the command line, and returnNone
otherwise.
val no_arg_abort : exit:(Base.Unit.t -> Nothing.t) -> 'a Flag.t
no_arg_abort ~exit
is likeno_arg
, but aborts command-line parsing by callingexit
. This flag type is useful for "help"-style flags that just print something and exit.
val escape : 'a Flag.t
escape
flags may be passed at most once. They cause the command line parser to abort and pass through all remaining command line arguments as the value of the flag.A standard choice of flag name to use with
escape
is"--"
.
include module type of Anons with type 'a t := 'a Anons.t
val (%:) : Base.String.t -> 'a Arg_type.t -> 'a Anons.t
(name %: typ)
specifies a required anonymous argument of typetyp
.The
name
must not be surrounded by whitespace; if it is, an exn will be raised.If the
name
is surrounded by a special character pair (<>, {}, [] or (),)name
will remain as-is, otherwise,name
will be uppercased.In the situation where
name
is only prefixed or only suffixed by one of the special character pairs, or different pairs are used (e.g., "<ARG]"), an exn will be raised.The (possibly transformed)
name
is mentioned in the generated help for the command.
val sequence : 'a Anons.t -> 'a Anons.t
sequence anons
specifies a sequence of anonymous arguments. An exception will be raised ifanons
matches anything other than a fixed number of anonymous arguments.
val non_empty_sequence_as_pair : 'a Anons.t -> 'a Anons.t
non_empty_sequence_as_pair anons
andnon_empty_sequence_as_list anons
are likesequence anons
except that an exception will be raised if there is not at least one anonymous argument given.
val non_empty_sequence_as_list : 'a Anons.t -> 'a Anons.t
val maybe : 'a Anons.t -> 'a Anons.t
(maybe anons)
indicates that some anonymous arguments are optional.
val maybe_with_default : 'a -> 'a Anons.t -> 'a Anons.t
(maybe_with_default default anons)
indicates an optional anonymous argument with a default value.
val t2 : 'a Anons.t -> 'a Anons.t -> 'a Anons.t
val t3 : 'a Anons.t -> 'a Anons.t -> 'a Anons.t -> 'a Anons.t
val t4 : 'a Anons.t -> 'a Anons.t -> 'a Anons.t -> 'a Anons.t -> 'a Anons.t
val map_anons : 'a Anons.t -> f:('a -> 'b) -> 'a Anons.t
map_anons anons ~f
transforms the parsed result ofanons
by applyingf
.