Module Deprecated_command.Annotated_field

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.

An example is as follows:

module M = struct
  type t = {
    field1 : int;
    field2 : float;
    field3 : bool;
    field4 : string option;
  } with fields

  module A = Annotated_field

  let ann_fields = Fields.fold ~init:[]
    ~field1:(A.required ~doc:" documentation for field1")
    ~field2:(A.default 1.0 string_of_float ~doc:" documentation for field2")
    ~field3:(A.set ~doc:" documentation for field3")
    ~field4:(A.optional ~doc:" documentation for field4")

  let command = create
    ~summary:"summary"
    ~init:(fun () -> A.init ann_fields)
    ~usage_arg:""
    ~flags:(List.map ann_fields ~f:A.to_flag)
    ~final:(fun accum _anon_args ->
      let get of_string = A.get accum of_string in
      let get_opt of_string = A.get_opt accum of_string in
      Fields.map
        ~field1:(get int_of_string)
        ~field2:(get Float.of_string)
        ~field3:(get bool_of_string)
        ~field4:(get_opt ident)
    )
    ~main:(fun _ -> assert false)
end

type t 
type accum 
val required : ?name:string ->
t list ->
doc:string ->
('a, 'b) Fieldslib.Field.t -> t list
val default : ?name:string ->
'field ->
('field -> string) ->
t list ->
doc:string ->
('a, 'field) Fieldslib.Field.t -> t list
val optional : ?name:string ->
?suppress_word_optional:bool ->
t list ->
doc:string ->
('a, 'b option) Fieldslib.Field.t ->
t list
val set : ?name:string ->
t list ->
doc:string ->
('a, bool) Fieldslib.Field.t -> t list
val clear : ?name:string ->
t list ->
doc:string ->
('a, bool) Fieldslib.Field.t -> t list
val list : ?name:string ->
t list ->
doc:string ->
('a, 'b list) Fieldslib.Field.t -> t list
val init : t list ->
accum
val to_flag : t ->
accum Deprecated_command.Flag.t
val get : accum ->
(string -> 'field) -> ('a, 'field) Fieldslib.Field.t -> 'field
val get_opt : accum ->
(string -> 'field) -> ('a, 'field option) Fieldslib.Field.t -> 'field option
val get_list : accum ->
(string -> 'field) -> ('a, 'field list) Fieldslib.Field.t -> 'field list