From 4d34efe71d285b72a80ce88f2da9d94fee2f6423 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 15 Dec 2016 07:09:44 -0800 Subject: [PATCH] [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 Path to the .inferconfig file --project-root | -pr 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 --- infer/src/base/CommandLineOption.ml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index abff13d33..640a30044 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -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 that all args can be parsed, but --help and parse failures only show external args for current exe *) + (* reset the speclist between calls to this function *) + curr_speclist := []; if current_exe = Toplevel then add_to_curr_speclist ~add_help:true ~header:"Toplevel options" current_exe else