[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
master
Jules Villard 5 years ago committed by Facebook Github Bot
parent f5ab894675
commit e4602ba0df

@ -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

Loading…
Cancel
Save