From 5bed34328048f0924692ad0e855a4f014c5f884d Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Fri, 2 Jun 2017 03:37:23 -0700 Subject: [PATCH] [commandline] Fix error option '' expects one of Reviewed By: jberdine Differential Revision: D5156883 fbshipit-source-id: 83c0b8c --- infer/src/base/CommandLineOption.ml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index 2707ef6e7..0dd07677e 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -105,9 +105,11 @@ type desc = { decode_json: inferconfig_dir:string -> Yojson.Basic.json -> string list ; } -let dashdash long = - match long with - | "" | "--" -> long +let dashdash ?short long = + match long, short with + | "", (None | Some "") + | "--", _ -> long + | "", Some short -> "-" ^ short | _ -> "--" ^ long let xdesc {long; short; spec} = @@ -118,7 +120,7 @@ let xdesc {long; short; spec} = | "", _ -> "-" ^ short | _ -> "--" ^ long in - let xspec long spec = + let xspec = match spec with (* translate Symbol to String for better formatting of --help messages *) | Symbol (symbols, action) -> @@ -127,13 +129,13 @@ let xdesc {long; short; spec} = action arg else 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 in (* 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 rec check_for_duplicates_ = function