module Deprecated_fcommand: Deprecated_fcommand
Fcommand.cmd ~summary:"Frobnicate something"
Fcommand.(
flag "-n" (required int) ~doc:"N number of times to frobnicate"
++ anon (args "item" string))
(fun n items -> ...)
type ('main_in, 'main_out) t
('main_in, 'main_out) t is a type of composable command-line
specifications.
Every combinator for building t-values is polymorphic in
'main_out. In the final specification expected by cmd used
to construct a command, 'main_out is specialized to unit).
Various primitive specifications add parameters one at a time,
so the resulting type of main is
arg1 -> ... -> argN -> unit
It may help to think of ('a, 'b) t as a function space 'a -> 'b
embellished with extra information about how to parse command line,
including documentation about what various flags are for.
type'aparse =string -> 'a
val string : string parseval int : int parseval float : float parseval date : Core.Date.t parseval sexp : Core.Sexp.t parsemodule Flag:sig..end
val required : 'a parse -> 'a Flag.tval optional : 'a parse -> 'a option Flag.tval optional_with_default : 'a -> 'a parse -> 'a Flag.tval listed : 'a parse -> 'a list Flag.tval no_arg : [ `Absent | `Present ] Flag.tval no_arg_bool : bool Flag.tval capture_remaining_command_line : string list option Flag.tval flag : string ->
'a Flag.t ->
doc:string -> ('a -> 'm, 'm) tmodule Anons:sig..end
val (%:) : string -> 'a parse -> 'a Anons.tval many : string -> 'a parse -> 'a list Anons.tval maybe : 'a Anons.t -> 'a option Anons.tval maybe_with_default : 'a -> 'a Anons.t -> 'a Anons.tval zero : unit Anons.tval t2 : 'a Anons.t ->
'b Anons.t -> ('a * 'b) Anons.tval t3 : 'a Anons.t ->
'b Anons.t ->
'c Anons.t -> ('a * 'b * 'c) Anons.tval t4 : 'a Anons.t ->
'b Anons.t ->
'c Anons.t ->
'd Anons.t ->
('a * 'b * 'c * 'd) Anons.tval anon : 'a Anons.t -> ('a -> 'm, 'm) tval empty : unit -> ('a, 'a) tval const : 'a -> ('a -> 'm, 'm) tval either : string ->
('a option -> 'b, 'a option -> 'a option -> 'b) tval (++) : ('m1, 'm2) t ->
('m2, 'm3) t -> ('m1, 'm3) tspec1 ++ spec2 composes command-line specifications spec1 and
spec2. Parameters specified by spec1 will come before those
specified by spec2 in the eventual main function.val either : string ->
('a option -> 'b, 'a option -> 'a option -> 'b) tval step : ('m1 -> 'm2) -> ('m1, 'm2) tstep allows you to transform the way parameters are applied. For
example, if you want labelled arguments, you can do:
Fcommand.cmd ~summary:"..."
Fcommand.(
step (fun main x y z -> main ~x ~y ~z)
++ flag "-x" (optional string) ~doc:"..."
++ flag "-y" (required string) ~doc:"..."
++ flag "-z" (optional int) ~doc:"..."
)
(fun ~x ~y ~z ->
...
)
val cmd : summary:string ->
?readme:(unit -> string) ->
?autocomplete:Deprecated_command.Autocomplete.t ->
?global_flags:unit Deprecated_command.Flag.t list ->
('main, unit) t -> 'main -> Deprecated_command.t