Up

Module Flag

Signature

type 'a t

type of flags to a command with accumulator type 'a

val name : _ t -> string
type ('a, 'b) create = string -> ?aliases:string list -> ?full_flag_required:bool -> 'b -> doc:string -> 'a t

Template for flag-creation functions

val of_arg : Core.Std.Arg.t -> unit t
Flag handling without an accumulator
val noarg : (unit, unit -> unit) create
val string : (unit, string -> unit) create
val int : (unit, int -> unit) create
val float : (unit, float -> unit) create
val bool : (unit, bool -> unit) create
val gen : (string -> 'gen) -> (unit, 'gen -> unit) create
val set_string : (unit, string Core.Std.ref) create
val set_string_opt : (unit, string option Core.Std.ref) create
val set_int : (unit, int Core.Std.ref) create
val set_int_opt : (unit, int option Core.Std.ref) create
val set_float : (unit, float Core.Std.ref) create
val set_float_opt : (unit, float option Core.Std.ref) create
val set_date : (unit, Core.Std.Date.t Core.Std.ref) create
val set_date_opt : (unit, Core.Std.Date.t option Core.Std.ref) create
val set : (unit, bool Core.Std.ref) create
val clear : (unit, bool Core.Std.ref) create
val set_gen : (string -> 'gen) -> (unit, 'gen Core.Std.ref) create
val set_gen_opt : (string -> 'gen) -> (unit, 'gen option Core.Std.ref) create
flag handling meant for use with immutable accumulator
val noarg_acc : ('a, 'a -> 'a) create
val string_acc : ('a, 'a -> string -> 'a) create
val int_acc : ('a, 'a -> int -> 'a) create
val bool_acc : ('a, 'a -> bool -> 'a) create
val float_acc : ('a, 'a -> float -> 'a) create
val date_acc : ('a, 'a -> Core.Std.Date.t -> 'a) create

rest f: a flag that signals the end of flag processing. all remaining arguments are passed to the f

val rest_acc : ('a, 'a -> string list -> 'a) create

rest f: a flag that signals the end of flag processing. all remaining arguments are passed to the f

val gen_acc : (string -> 'gen) -> ('a, 'a -> 'gen -> 'a) create
flag handling meant for use with mutable accumulator
val noarg_mut : ('a, 'a -> unit) create
val arg_mut : ('a, 'a -> string -> unit) create
val string_mut : ('a, 'a -> string -> unit) create
val int_mut : ('a, 'a -> int -> unit) create
val bool_mut : ('a, 'a -> bool -> unit) create
val float_mut : ('a, 'a -> float -> unit) create
val date_mut : ('a, 'a -> Core.Std.Date.t -> unit) create

rest f: a flag that signals the end of flag processing. all remaining arguments are passed to the f

val rest_mut : ('a, 'a -> string list -> unit) create

rest f: a flag that signals the end of flag processing. all remaining arguments are passed to the f

val gen_mut : (string -> 'gen) -> ('a, 'a -> 'gen -> unit) create
module Action : sig .. end
val create : ?aliases:string list -> ?full_flag_required:bool -> name:string -> doc:string -> 'a Action.t -> 'a t
val lift : 'a t -> project:('b -> 'a * ('a -> 'b)) -> 'b t

lift t ~project transforms a flag with accumulator type 'a into a flag with a more informative accumulator type 'b provided that project x returns a pair consisting of 1. a 'a-value extracted from the 'b-value x, and 2. a function for rebuilding a modified 'b-value from the modified 'a-value resulting from processing the flag.

The intended use pattern for lift is when 'b is a record type with a field foo of type 'a and project is fun r -> (r.foo, (fun foo' -> { r with foo = foo' }))

val lift_unit : unit t -> 'any t
val to_spec : ('accum -> 'accum) Core.Std.ref -> 'accum t -> ('c, 'c) Core.Std.Command.Spec.t
val to_spec_unit : unit t -> ('c, 'c) Core.Std.Command.Spec.t
val to_spec_units : unit t list -> ('c, 'c) Core.Std.Command.Spec.t