[toplevel] fix double-printing of infer options in --help

Summary:
The list of argument specs is a global ref inside `CommandLineOptions`, which
need to be reset to the empty list every time `parse` is called. Otherwise, we
get duplicated sections:

```
$ infer --help
Infer version v0.9.4-84d61cb
Copyright 2009 - present Facebook. All Rights Reserved.

  Toplevel options

  --inferconfig-home <dir>   Path to the .inferconfig file
  --project-root | -pr <dir> Specify the root directory of the project (default: /home/jul/infer)

  Analysis (backend) options

  Clang frontend options

  Java frontend options

  Toplevel options

[... the rest of the options -- without --inferconfig-home or --project-root,
      with all the section headers again ...]
```

Reviewed By: jberdine

Differential Revision: D4333448

fbshipit-source-id: f91ea66
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent fb34f30350
commit 4d34efe71d

@ -621,6 +621,8 @@ let parse ?(incomplete=false) ?(accept_unknown=false) ?config_file current_exe e
(* speclist includes args for current exe with docs, and all other args without docs, so (* speclist includes args for current exe with docs, and all other args without docs, so
that all args can be parsed, but --help and parse failures only show external args for that all args can be parsed, but --help and parse failures only show external args for
current exe *) current exe *)
(* reset the speclist between calls to this function *)
curr_speclist := [];
if current_exe = Toplevel then if current_exe = Toplevel then
add_to_curr_speclist ~add_help:true ~header:"Toplevel options" current_exe add_to_curr_speclist ~add_help:true ~header:"Toplevel options" current_exe
else else

Loading…
Cancel
Save