diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index 0dd07677e..92d86df23 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -339,25 +339,27 @@ let mk_bool ?(deprecated_no=[]) ?(default=false) ?(f=fun b -> b) ~mk_spec ); 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 = let f b = List.iter ~f:(fun child -> child := b) children ; List.iter ~f:(fun child -> child := not b) no_children ; - b + f0 b in 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 ~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) ~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 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 let mk_float ~default ?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?(meta="float") doc = diff --git a/infer/src/base/CommandLineOption.mli b/infer/src/base/CommandLineOption.mli index 4a8c750fc..c8975917b 100644 --- a/infer/src/base/CommandLineOption.mli +++ b/infer/src/base/CommandLineOption.mli @@ -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 "--no-child" later in the arguments. *) 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