[commandline] Fix error option '' expects one of

Reviewed By: jberdine

Differential Revision: D5156883

fbshipit-source-id: 83c0b8c
master
Mehdi Bouaziz 8 years ago committed by Facebook Github Bot
parent 6fc287656f
commit 5bed343280

@ -105,9 +105,11 @@ type desc = {
decode_json: inferconfig_dir:string -> Yojson.Basic.json -> string list ; decode_json: inferconfig_dir:string -> Yojson.Basic.json -> string list ;
} }
let dashdash long = let dashdash ?short long =
match long with match long, short with
| "" | "--" -> long | "", (None | Some "")
| "--", _ -> long
| "", Some short -> "-" ^ short
| _ -> "--" ^ long | _ -> "--" ^ long
let xdesc {long; short; spec} = let xdesc {long; short; spec} =
@ -118,7 +120,7 @@ let xdesc {long; short; spec} =
| "", _ -> "-" ^ short | "", _ -> "-" ^ short
| _ -> "--" ^ long | _ -> "--" ^ long
in in
let xspec long spec = let xspec =
match spec with match spec with
(* translate Symbol to String for better formatting of --help messages *) (* translate Symbol to String for better formatting of --help messages *)
| Symbol (symbols, action) -> | Symbol (symbols, action) ->
@ -127,13 +129,13 @@ let xdesc {long; short; spec} =
action arg action arg
else else
raise (Arg.Bad (F.sprintf "wrong argument '%s'; option '%s' expects one of: %s" raise (Arg.Bad (F.sprintf "wrong argument '%s'; option '%s' expects one of: %s"
arg (dashdash long) (String.concat ~sep:" | " symbols))) arg (dashdash ~short long) (String.concat ~sep:" | " symbols)))
) )
| _ -> | _ ->
spec spec
in in
(* Arg doesn't need to know anything about documentation since we generate our own *) (* Arg doesn't need to know anything about documentation since we generate our own *)
(key long short, xspec long spec, "") (key long short, xspec, "")
let check_no_duplicates desc_list = let check_no_duplicates desc_list =
let rec check_for_duplicates_ = function let rec check_for_duplicates_ = function

Loading…
Cancel
Save