Fix --help and friends that 2 phase parsing broke

Summary:
Two phase parsing of command line options, part of unifying command
line options and .inferconfig, broke the --help and --help-full usage
messages.  This diff fixes them.

Reviewed By: jvillard

Differential Revision: D3435521

fbshipit-source-id: d4ecbb1
master
Josh Berdine 9 years ago committed by Facebook Github Bot 9
parent 8d3e7e774e
commit 3a47b4064b

@ -391,16 +391,24 @@ let parse ?(incomplete=false) ?config_file env_var exe_usage =
Arg.usage !full_speclist usage_msg ; Arg.usage !full_speclist usage_msg ;
exit status exit status
in in
let help_desc_list = let add_or_suppress_help speclist =
[ { long = "help"; short = ""; meta = ""; decode_json = (fun _ -> []); let unknown opt =
spec = Arg.Unit (fun () -> curr_usage 0); (opt, Arg.Unit (fun () -> raise (Arg.Bad ("unknown option '" ^ opt ^ "'"))), "") in
doc = "Display this list of options" } if incomplete then
; { long = "help-full"; short = ""; meta = ""; decode_json = (fun _ -> []); speclist @ [
spec = Arg.Unit (fun () -> full_usage 0); (unknown "--help") ;
doc = "Display the full list of options, including internal and experimental options" } (unknown "-help")
] in ]
else
speclist @ [
("--help", Arg.Unit (fun () -> curr_usage 0),
"Display this list of options") ;
("--help-full", Arg.Unit (fun () -> full_usage 0),
"Display the full list of options, including internal and experimental options") ;
(unknown "-help")
]
in
let normalize speclist = let normalize speclist =
let speclist = help_desc_list @ speclist in
let norm k = let norm k =
let len = String.length k in let len = String.length k in
if len > 3 && String.sub k 0 3 = "no-" then String.sub k 3 (len - 3) else k in if len > 3 && String.sub k 0 3 = "no-" then String.sub k 3 (len - 3) else k in
@ -411,9 +419,7 @@ let parse ?(incomplete=false) ?config_file env_var exe_usage =
| _, "--" -> -1 | _, "--" -> -1
| _ -> String.compare (norm x) (norm y) in | _ -> String.compare (norm x) (norm y) in
let sort speclist = IList.sort compare_specs speclist in let sort speclist = IList.sort compare_specs speclist in
let suppress_help speclist = add_or_suppress_help (align ~limit:46 (sort speclist))
("-help", Arg.Unit (fun () -> raise (Arg.Bad "unknown option '-help'")), "") :: speclist in
suppress_help (align ~limit:32 (sort speclist))
in in
let curr_desc_list = IList.assoc ( = ) current_exe exe_desc_lists let curr_desc_list = IList.assoc ( = ) current_exe exe_desc_lists
in in

Loading…
Cancel
Save