[CLOpt] add option `f` argument to a bunch more `mk_*` functions

Summary: Needed higher-up the stack, useful to have in the API in general.

Reviewed By: jberdine

Differential Revision: D5165153

fbshipit-source-id: 714aeea
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 0404641ab3
commit 2608ec67c3

@ -339,25 +339,27 @@ let mk_bool ?(deprecated_no=[]) ?(default=false) ?(f=fun b -> b)
~mk_spec ); ~mk_spec );
var var
let mk_bool_group ?(deprecated_no=[]) ?(default=false) let mk_bool_group ?(deprecated_no=[]) ?(default=false) ?f:(f0=Fn.id)
?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?meta doc children no_children = ?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?meta doc children no_children =
let f b = let f b =
List.iter ~f:(fun child -> child := b) children ; List.iter ~f:(fun child -> child := b) children ;
List.iter ~f:(fun child -> child := not b) no_children ; List.iter ~f:(fun child -> child := not b) no_children ;
b f0 b
in in
mk_bool ~deprecated ~deprecated_no ~default ~long ?short ~f ?parse_mode ?in_help ?meta doc mk_bool ~deprecated ~deprecated_no ~default ~long ?short ~f ?parse_mode ?in_help ?meta doc
let mk_int ~default ?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?(meta="int") doc = let mk_int ~default ?(f=Fn.id)
?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?(meta="int") doc =
mk ~deprecated ~long ?short ~default ?parse_mode ?in_help ~meta doc mk ~deprecated ~long ?short ~default ?parse_mode ?in_help ~meta doc
~default_to_string:string_of_int ~default_to_string:string_of_int
~mk_setter:(fun var str -> var := (int_of_string str)) ~mk_setter:(fun var str -> var := f (int_of_string str))
~decode_json:(string_json_decoder ~long) ~decode_json:(string_json_decoder ~long)
~mk_spec:(fun set -> String set) ~mk_spec:(fun set -> String set)
let mk_int_opt ?default ?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?(meta="int") doc = let mk_int_opt ?default ?f:(f0=Fn.id)
?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?(meta="int") doc =
let default_to_string = function Some f -> string_of_int f | None -> "" in let default_to_string = function Some f -> string_of_int f | None -> "" in
let f s = Some (int_of_string s) in let f s = Some (f0 (int_of_string s)) in
mk_option ~deprecated ~long ?short ~default ~default_to_string ~f ?parse_mode ?in_help ~meta doc mk_option ~deprecated ~long ?short ~default ~default_to_string ~f ?parse_mode ?in_help ~meta doc
let mk_float ~default ?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?(meta="float") doc = let mk_float ~default ?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?(meta="float") doc =

@ -84,11 +84,12 @@ val mk_bool : ?deprecated_no:string list -> ?default:bool -> ?f:(bool -> bool)
[children] are also set and the [no_children] are unset. A child can be unset by including [children] are also set and the [no_children] are unset. A child can be unset by including
"--no-child" later in the arguments. *) "--no-child" later in the arguments. *)
val mk_bool_group : val mk_bool_group :
?deprecated_no:string list -> ?default:bool -> (bool ref list -> bool ref list -> bool ref) t ?deprecated_no:string list -> ?default:bool -> ?f:(bool -> bool) ->
(bool ref list -> bool ref list -> bool ref) t
val mk_int : default:int -> int ref t val mk_int : default:int -> ?f:(int -> int) -> int ref t
val mk_int_opt : ?default:int -> int option ref t val mk_int_opt : ?default:int -> ?f:(int -> int) -> int option ref t
val mk_float : default:float -> float ref t val mk_float : default:float -> float ref t

Loading…
Cancel
Save