From e4602ba0df460ea37ebca7780111e02448aba769 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 10 Mar 2020 03:09:34 -0700 Subject: [PATCH] [clopt] do not generate "--no-" flag for [mk_bool ~long:""] Summary: Some options are deprecated and this is indicated with `~long:""`. But for boolean options this creates a spurious `"--no-"` flag. Detect when the option has an empty flag and don't create the "no" version in that case. Reviewed By: ngorogiannis Differential Revision: D20286830 fbshipit-source-id: 9a2095ea8 --- infer/src/base/CommandLineOption.ml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index d8b1d946b..26a40fbca 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -447,13 +447,14 @@ let mk_bool ?(deprecated_no = []) ?(default = false) ?(f = fun b -> b) ?(depreca [dashdash (if YBU.to_bool json then long else nolong)] ) ~mk_spec in - ignore - (mk ~long:nolong ?short:noshort ~deprecated:deprecated_no ~default:(not default) ?parse_mode - ?in_help ~meta nodoc ~default_to_string - ~mk_setter:(fun _ _ -> var := f false) - ~decode_json:(fun ~inferconfig_dir:_ json -> - [dashdash (if YBU.to_bool json then nolong else long)] ) - ~mk_spec) ; + if not (String.is_empty long) then + ignore + (mk ~long:nolong ?short:noshort ~deprecated:deprecated_no ~default:(not default) ?parse_mode + ?in_help ~meta nodoc ~default_to_string + ~mk_setter:(fun _ _ -> var := f false) + ~decode_json:(fun ~inferconfig_dir:_ json -> + [dashdash (if YBU.to_bool json then nolong else long)] ) + ~mk_spec) ; var