[command line] Fix json deserialization of mk_path_list

Reviewed By: jvillard

Differential Revision: D4327520

fbshipit-source-id: 0237905
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent 16cae31f20
commit 1bb6401d15

@ -355,7 +355,7 @@ let mk_string_list ?(default=[]) ?(f=fun s -> s)
~mk_spec:(fun set -> Arg.String set) ~mk_spec:(fun set -> Arg.String set)
let mk_path_helper ~setter ~default_to_string let mk_path_helper ~setter ~default_to_string
~default ~deprecated ~long ~short ~exes ~meta doc = ~default ~deprecated ~long ~short ~exes ~meta ~decode_json doc =
let normalize_path_in_args_being_parsed str = let normalize_path_in_args_being_parsed str =
if Filename.is_relative str then ( if Filename.is_relative str then (
(* Replace relative paths with absolute ones on the fly in the args being parsed. This assumes (* Replace relative paths with absolute ones on the fly in the args being parsed. This assumes
@ -368,26 +368,30 @@ let mk_path_helper ~setter ~default_to_string
) else ) else
str in str in
mk ~deprecated ~long ?short ~default ?exes ~meta doc mk ~deprecated ~long ?short ~default ?exes ~meta doc
~default_to_string ~decode_json ~default_to_string
~mk_setter:(fun var str -> ~mk_setter:(fun var str ->
let abs_path = normalize_path_in_args_being_parsed str in let abs_path = normalize_path_in_args_being_parsed str in
setter var abs_path) setter var abs_path)
~decode_json:(string_json_decoder ~long)
~mk_spec:(fun set -> Arg.String set) ~mk_spec:(fun set -> Arg.String set)
let mk_path ~default ?(deprecated=[]) ~long ?short ?exes ?(meta="path") = let mk_path ~default ?(deprecated=[]) ~long ?short ?exes ?(meta="path") =
mk_path_helper ~setter:(fun var x -> var := x) ~default_to_string:(fun s -> s) mk_path_helper
~setter:(fun var x -> var := x)
~decode_json:(string_json_decoder ~long)
~default_to_string:(fun s -> s)
~default ~deprecated ~long ~short ~exes ~meta ~default ~deprecated ~long ~short ~exes ~meta
let mk_path_opt ?default ?(deprecated=[]) ~long ?short ?exes ?(meta="path") = let mk_path_opt ?default ?(deprecated=[]) ~long ?short ?exes ?(meta="path") =
mk_path_helper mk_path_helper
~setter:(fun var x -> var := Some x) ~setter:(fun var x -> var := Some x)
~decode_json:(string_json_decoder ~long)
~default_to_string:(function Some s -> s | None -> "") ~default_to_string:(function Some s -> s | None -> "")
~default ~deprecated ~long ~short ~exes ~meta ~default ~deprecated ~long ~short ~exes ~meta
let mk_path_list ?(default=[]) ?(deprecated=[]) ~long ?short ?exes ?(meta="path") = let mk_path_list ?(default=[]) ?(deprecated=[]) ~long ?short ?exes ?(meta="path") =
mk_path_helper mk_path_helper
~setter:(fun var x -> var := x :: !var) ~setter:(fun var x -> var := x :: !var)
~decode_json:(list_json_decoder (string_json_decoder ~long))
~default_to_string:(String.concat ~sep:", ") ~default_to_string:(String.concat ~sep:", ")
~default ~deprecated ~long ~short ~exes ~meta ~default ~deprecated ~long ~short ~exes ~meta

Loading…
Cancel
Save