[cli] deprecate multiletter short options

Summary:
We want to stop supporting '-multiletter' options altogether in the future as
they are not standard.

For boolean switches, we used to have '-short' for true and '-nshort' for
false, but that second form is necessarily > 1 letters, which doesn't work in
this scheme. Replace these by '-s' for true and '-S' for false.

Reviewed By: jberdine

Differential Revision: D4674079

fbshipit-source-id: 95bacfe
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 8ab1adf40d
commit dba740632c

@ -282,7 +282,7 @@ let deprecate_desc parse_mode ~long ~short ~deprecated desc =
spec = deprecated_spec; decode_json = deprecated_decode_json } spec = deprecated_spec; decode_json = deprecated_decode_json }
let mk ?(deprecated=[]) ?(parse_mode=Infer []) let mk ?(deprecated=[]) ?(parse_mode=Infer [])
~long ?(short="") ~default ~meta doc ~default_to_string ~decode_json ~mk_setter ~mk_spec = ~long ?short:short0 ~default ~meta doc ~default_to_string ~decode_json ~mk_setter ~mk_spec =
let variable = ref default in let variable = ref default in
let closure = mk_setter variable in let closure = mk_setter variable in
let setter str = let setter str =
@ -295,7 +295,8 @@ let mk ?(deprecated=[]) ?(parse_mode=Infer [])
let default_string = default_to_string default in let default_string = default_to_string default in
if default_string = "" then doc if default_string = "" then doc
else doc ^ " (default: " ^ default_string ^ ")" in else doc ^ " (default: " ^ default_string ^ ")" in
let desc = {long; short; meta; doc; spec; decode_json} in let short = match short0 with Some c -> String.of_char c | None -> "" in
let desc = {long; short=short; meta; doc; spec; decode_json} in
(* add desc for long option, with documentation (which includes any short option) for exes *) (* add desc for long option, with documentation (which includes any short option) for exes *)
if long <> "" then add parse_mode desc ; if long <> "" then add parse_mode desc ;
(* add desc for short option only for parsing, without documentation *) (* add desc for short option only for parsing, without documentation *)
@ -306,7 +307,7 @@ let mk ?(deprecated=[]) ?(parse_mode=Infer [])
add parse_mode_no_sections {desc with long = ""; meta = ""; doc = ""} ; add parse_mode_no_sections {desc with long = ""; meta = ""; doc = ""} ;
(* add desc for deprecated options only for parsing, without documentation *) (* add desc for deprecated options only for parsing, without documentation *)
List.iter deprecated ~f:(fun deprecated -> List.iter deprecated ~f:(fun deprecated ->
deprecate_desc parse_mode ~long ~short ~deprecated desc deprecate_desc parse_mode ~long ~short:short ~deprecated desc
|> add parse_mode_no_sections) ; |> add parse_mode_no_sections) ;
variable variable
@ -338,7 +339,7 @@ let final_parse_action = ref (Infer Driver)
(* end parsing state *) (* end parsing state *)
type 'a t = type 'a t =
?deprecated:string list -> long:Arg.key -> ?short:Arg.key -> ?deprecated:string list -> long:Arg.key -> ?short:char ->
?parse_mode:parse_mode -> ?meta:string -> Arg.doc -> ?parse_mode:parse_mode -> ?meta:string -> Arg.doc ->
'a 'a
@ -373,23 +374,20 @@ let mk_bool ?(deprecated_no=[]) ?(default=false) ?(f=fun b -> b)
"no-" ^ long "no-" ^ long
and noshort = and noshort =
Option.map ~f:(fun short -> Option.map ~f:(fun short ->
let len = String.length short in if Char.is_lowercase short then Char.uppercase short
if len > 1 && String.sub short ~pos:0 ~len:1 = "n" then else Char.lowercase short
String.sub short ~pos:1 ~len:(len - 1)
else
"n" ^ short
) short ) short
in in
let doc nolong = let doc long short =
match noshort with match short with
| Some noshort -> doc ^ " (Conversely: --" ^ nolong ^ " | -" ^ noshort ^ ")" | Some short -> doc ^ " (Conversely: --" ^ long ^ " | -" ^ String.of_char short ^ ")"
| None -> doc ^ " (Conversely: --" ^ nolong ^ ")" | None -> doc ^ " (Conversely: --" ^ long ^ ")"
in in
let doc, nodoc = let doc, nodoc =
if not default then if not default then
("Activates: " ^ doc nolong, "") ("Activates: " ^ doc nolong noshort, "")
else else
("", "Deactivates: " ^ doc long) in ("", "Deactivates: " ^ doc long short) in
let default_to_string _ = "" in let default_to_string _ = "" in
let mk_spec set = Unit (fun () -> set "") in let mk_spec set = Unit (fun () -> set "") in
let var = let var =

@ -47,7 +47,7 @@ val init_work_dir : string
- a documentation string - a documentation string
*) *)
type 'a t = type 'a t =
?deprecated:string list -> long:string -> ?short:string -> ?deprecated:string list -> long:string -> ?short:char ->
?parse_mode:parse_mode -> ?meta:string -> string -> ?parse_mode:parse_mode -> ?meta:string -> string ->
'a 'a
@ -59,8 +59,8 @@ val mk_option :
'a option ref t 'a option ref t
(** [mk_bool long short doc] defines a [bool ref] set by the command line flag [--long] (and (** [mk_bool long short doc] defines a [bool ref] set by the command line flag [--long] (and
[-short]), and cleared by the flag [--no-long] (and [-nshort]). If [long] already has a "no-", [-s]), and cleared by the flag [--no-long] (and [-S]). If [long] already has a "no-" prefix,
or [short] nas an "n", prefix, then the existing prefixes will instead be removed. The default or [s] is capital, then the existing prefixes will instead be removed. The default
value is [false] unless overridden by [~default:true]. The [doc] string will be prefixed with value is [false] unless overridden by [~default:true]. The [doc] string will be prefixed with
either "Activates:" or "Deactivates:", so should be phrased accordingly. *) either "Activates:" or "Deactivates:", so should be phrased accordingly. *)
val mk_bool : ?deprecated_no:string list -> ?default:bool -> ?f:(bool -> bool) -> bool ref t val mk_bool : ?deprecated_no:string list -> ?default:bool -> ?f:(bool -> bool) -> bool ref t

@ -384,7 +384,7 @@ let inferconfig_home =
~parse_mode:CLOpt.(Infer all_sections) ~meta:"dir" "Path to the .inferconfig file" ~parse_mode:CLOpt.(Infer all_sections) ~meta:"dir" "Path to the .inferconfig file"
and project_root = and project_root =
CLOpt.mk_path ~deprecated:["project_root"; "-project_root"] ~long:"project-root" ~short:"pr" CLOpt.mk_path ~deprecated:["project_root"; "-project_root"; "pr"] ~long:"project-root" ~short:'C'
~default:CLOpt.init_work_dir ~default:CLOpt.init_work_dir
~parse_mode:CLOpt.(Infer [Analysis;Clang;Driver;Print]) ~parse_mode:CLOpt.(Infer [Analysis;Clang;Driver;Print])
~meta:"dir" "Specify the root directory of the project" ~meta:"dir" "Specify the root directory of the project"
@ -513,7 +513,7 @@ and analyzer =
documentation of this option *) documentation of this option *)
| Capture | Compile | Infer | Eradicate | Checkers | Tracing | Crashcontext | Linters | Capture | Compile | Infer | Eradicate | Checkers | Tracing | Crashcontext | Linters
| Quandary | Threadsafety | Bufferoverrun -> () in | Quandary | Threadsafety | Bufferoverrun -> () in
CLOpt.mk_symbol_opt ~deprecated:["analyzer"] ~long:"analyzer" ~short:"a" CLOpt.mk_symbol_opt ~deprecated:["analyzer"] ~long:"analyzer" ~short:'a'
~parse_mode:CLOpt.(Infer [Driver]) ~parse_mode:CLOpt.(Infer [Driver])
"Specify which analyzer to run (only one at a time is supported):\n\ "Specify which analyzer to run (only one at a time is supported):\n\
- infer, eradicate, checkers, quandary, threadsafety, bufferoverrun: run the specified analysis\n\ - infer, eradicate, checkers, quandary, threadsafety, bufferoverrun: run the specified analysis\n\
@ -546,7 +546,7 @@ and array_level =
- 2 = assumes that all heap dereferences via array indexing and pointer \ - 2 = assumes that all heap dereferences via array indexing and pointer \
arithmetic are correct" arithmetic are correct"
and ast_file = and ast_file =
CLOpt.mk_path_opt ~long:"ast-file" ~short:"ast" CLOpt.mk_path_opt ~deprecated:["ast"] ~long:"ast-file"
~meta:"file" "AST file for the translation" ~meta:"file" "AST file for the translation"
and blacklist = and blacklist =
@ -752,7 +752,7 @@ and (
"Show internal exceptions" "Show internal exceptions"
and filtering = and filtering =
CLOpt.mk_bool ~long:"filtering" ~short:"f" ~default:true CLOpt.mk_bool ~deprecated_no:["nf"] ~long:"filtering" ~short:'f' ~default:true
~parse_mode:CLOpt.(Infer [Driver]) ~parse_mode:CLOpt.(Infer [Driver])
"Do not show the results from experimental checks (note: some of them may contain many false \ "Do not show the results from experimental checks (note: some of them may contain many false \
alarms)" alarms)"
@ -788,7 +788,7 @@ and (
"Produce dotty files for specs in the results directory" "Produce dotty files for specs in the results directory"
in in
let debug = let debug =
CLOpt.mk_bool_group ~deprecated:["debug"] ~long:"debug" ~short:"g" CLOpt.mk_bool_group ~deprecated:["debug"] ~long:"debug" ~short:'g'
~parse_mode:CLOpt.(Infer [Driver]) ~parse_mode:CLOpt.(Infer [Driver])
"Debug mode (also sets --developer-mode, --no-filtering, --print-buckets, --print-types, \ "Debug mode (also sets --developer-mode, --no-filtering, --print-buckets, --print-types, \
--reports-include-ml-loc, --no-test, --trace-error, --write-dotty, --write-html)" --reports-include-ml-loc, --no-test, --trace-error, --write-dotty, --write-html)"
@ -938,12 +938,12 @@ and from_json_report =
files generated by the analysis)." files generated by the analysis)."
and frontend_debug = and frontend_debug =
CLOpt.mk_bool ~long:"frontend-debug" ~short:"fd" CLOpt.mk_bool ~deprecated:["fd"] ~deprecated_no:["nfd"] ~long:"frontend-debug"
"Emit debug info to *.o.astlog and a script *.o.sh that replays the command used to run clang \ "Emit debug info to *.o.astlog and a script *.o.sh that replays the command used to run clang \
with the plugin attached, piped to the InferClang frontend command (clang only)" with the plugin attached, piped to the InferClang frontend command (clang only)"
and frontend_stats = and frontend_stats =
CLOpt.mk_bool ~long:"frontend-stats" ~short:"fs" CLOpt.mk_bool ~deprecated:["fs"] ~deprecated_no:["nfs"] ~long:"frontend-stats"
"Output statistics about the capture phase to *.o.astlog (clang only)" "Output statistics about the capture phase to *.o.astlog (clang only)"
and frontend_tests = and frontend_tests =
@ -957,7 +957,7 @@ and generated_classes =
"Specify where to load the generated class files" "Specify where to load the generated class files"
and headers = and headers =
CLOpt.mk_bool ~deprecated:["headers"] ~deprecated_no:["no_headers"] ~long:"headers" ~short:"hd" CLOpt.mk_bool ~deprecated:["headers"; "hd"] ~deprecated_no:["no_headers"; "nhd"] ~long:"headers"
~parse_mode:CLOpt.(Infer [Clang]) ~parse_mode:CLOpt.(Infer [Clang])
"Analyze code in header files" "Analyze code in header files"
@ -999,7 +999,7 @@ and java_jar_compiler =
~meta:"path" "Specifify the Java compiler jar used to generate the bytecode" ~meta:"path" "Specifify the Java compiler jar used to generate the bytecode"
and jobs = and jobs =
CLOpt.mk_int ~deprecated:["-multicore"] ~long:"jobs" ~short:"j" ~default:ncpu CLOpt.mk_int ~deprecated:["-multicore"] ~long:"jobs" ~short:'j' ~default:ncpu
~parse_mode:CLOpt.(Infer [Driver]) ~parse_mode:CLOpt.(Infer [Driver])
~meta:"int" "Run the specified number of analysis jobs simultaneously" ~meta:"int" "Run the specified number of analysis jobs simultaneously"
@ -1025,7 +1025,7 @@ and linters_developer_mode =
default linters and also sets --print-logs, --debug and --no-allowed-failures." default linters and also sets --print-logs, --debug and --no-allowed-failures."
and load_average = and load_average =
CLOpt.mk_float_opt ~long:"load-average" ~short:"l" CLOpt.mk_float_opt ~long:"load-average" ~short:'l'
~parse_mode:CLOpt.(Infer [Driver]) ~meta:"float" ~parse_mode:CLOpt.(Infer [Driver]) ~meta:"float"
"Do not start new parallel jobs if the load average is greater than that specified (Buck and \ "Do not start new parallel jobs if the load average is greater than that specified (Buck and \
make only)" make only)"
@ -1145,7 +1145,8 @@ and procs_xml =
--results-dir)" --results-dir)"
and progress_bar = and progress_bar =
CLOpt.mk_bool ~deprecated_no:["no_progress_bar"] ~long:"progress-bar" ~short:"pb" ~default:true CLOpt.mk_bool ~deprecated:["pb"] ~deprecated_no:["no_progress_bar"; "npb"] ~short:'p'
~long:"progress-bar" ~default:true
~parse_mode:CLOpt.(Infer [Driver]) ~parse_mode:CLOpt.(Infer [Driver])
"Show a progress bar" "Show a progress bar"
@ -1160,12 +1161,12 @@ and quandary_sinks =
"Specify custom sinks for Quandary" "Specify custom sinks for Quandary"
and quiet = and quiet =
CLOpt.mk_bool ~long:"quiet" ~short:"q" ~default:(current_exe <> Print) CLOpt.mk_bool ~long:"quiet" ~short:'q' ~default:(current_exe <> Print)
~parse_mode:CLOpt.(Infer [Print]) ~parse_mode:CLOpt.(Infer [Print])
"Do not print specs on standard output" "Do not print specs on standard output"
and reactive = and reactive =
CLOpt.mk_bool ~deprecated:["reactive"] ~long:"reactive" ~short:"r" CLOpt.mk_bool ~deprecated:["reactive"] ~long:"reactive" ~short:'r'
"Reactive mode: the analysis starts from the files captured since the `infer` command started" "Reactive mode: the analysis starts from the files captured since the `infer` command started"
and reactive_capture = and reactive_capture =
@ -1213,7 +1214,7 @@ and rest =
) )
and results_dir = and results_dir =
CLOpt.mk_path ~deprecated:["results_dir"; "-out"] ~long:"results-dir" ~short:"o" CLOpt.mk_path ~deprecated:["results_dir"; "-out"] ~long:"results-dir" ~short:'o'
~default:(CLOpt.init_work_dir ^/ "infer-out") ~default:(CLOpt.init_work_dir ^/ "infer-out")
~parse_mode:CLOpt.(Infer [Analysis;Clang;Driver;Print]) ~parse_mode:CLOpt.(Infer [Analysis;Clang;Driver;Print])
~meta:"dir" "Write results and internal files in the specified directory" ~meta:"dir" "Write results and internal files in the specified directory"
@ -1264,7 +1265,7 @@ and spec_abs_level =
and specs_library = and specs_library =
let specs_library = let specs_library =
CLOpt.mk_path_list ~long:"specs-library" ~short:"lib" CLOpt.mk_path_list ~deprecated:["lib"] ~long:"specs-library" ~short:'L'
~meta:"dir|jar" "Search for .spec files in given directory or jar file" in ~meta:"dir|jar" "Search for .spec files in given directory or jar file" in
let _ = let _ =
(* Given a filename with a list of paths, convert it into a list of string iff they are (* Given a filename with a list of paths, convert it into a list of string iff they are
@ -1290,7 +1291,7 @@ and specs_library =
specs_library specs_library
and stacktrace = and stacktrace =
CLOpt.mk_path_opt ~long:"stacktrace" ~short:"st" ~parse_mode:CLOpt.(Infer [Crashcontext]) CLOpt.mk_path_opt ~deprecated:["st"] ~long:"stacktrace" ~parse_mode:CLOpt.(Infer [Crashcontext])
~meta:"file" "File path containing a json-encoded Java crash stacktrace. Used to guide the \ ~meta:"file" "File path containing a json-encoded Java crash stacktrace. Used to guide the \
analysis (only with '-a crashcontext'). See \ analysis (only with '-a crashcontext'). See \
tests/codetoanalyze/java/crashcontext/*.json for examples of the expected format." tests/codetoanalyze/java/crashcontext/*.json for examples of the expected format."
@ -1321,7 +1322,8 @@ and test_filtering =
"List all the files Infer can report on (should be called from the root of the project)" "List all the files Infer can report on (should be called from the root of the project)"
and testing_mode = and testing_mode =
CLOpt.mk_bool ~deprecated:["testing_mode"; "-testing_mode"] ~long:"testing-mode" ~short:"tm" CLOpt.mk_bool ~deprecated:["testing_mode"; "-testing_mode"; "tm"] ~deprecated_no:["ntm"]
~long:"testing-mode"
"Mode for testing, where no headers are translated, and dot files are created (clang only)" "Mode for testing, where no headers are translated, and dot files are created (clang only)"
and threadsafe_aliases = and threadsafe_aliases =
@ -1413,7 +1415,7 @@ and xml_specs =
Infer.run_javac for a version that looks inside argfiles, and discussion in D4397716. *) Infer.run_javac for a version that looks inside argfiles, and discussion in D4397716. *)
let javac_classes_out = let javac_classes_out =
CLOpt.mk_string ~parse_mode:CLOpt.Javac CLOpt.mk_string ~parse_mode:CLOpt.Javac
~deprecated:["classes_out"] ~short:"d" ~long:"" ~default:CLOpt.init_work_dir ~deprecated:["classes_out"] ~long:"" ~short:'d' ~default:CLOpt.init_work_dir
~f:(fun classes_out -> ~f:(fun classes_out ->
if !buck then ( if !buck then (
let classes_out_infer = resolve classes_out ^/ buck_results_dir_name in let classes_out_infer = resolve classes_out ^/ buck_results_dir_name in
@ -1426,7 +1428,7 @@ let javac_classes_out =
and java_classpath = and java_classpath =
CLOpt.mk_string_opt ~parse_mode:CLOpt.Javac CLOpt.mk_string_opt ~parse_mode:CLOpt.Javac
~deprecated:["classpath"] ~short:"cp" ~long:"" ~deprecated:["classpath";"cp"] ~long:""
~f:(fun classpath -> ~f:(fun classpath ->
if !buck then ( if !buck then (
let paths = String.split classpath ~on:':' in let paths = String.split classpath ~on:':' in

@ -12,7 +12,7 @@ TESTS_DIR = ../../..
ANALYZER = bufferoverrun ANALYZER = bufferoverrun
CLANG_OPTIONS = -c CLANG_OPTIONS = -c
INFER_OPTIONS = -nf --project-root $(TESTS_DIR) --no-failures-allowed INFER_OPTIONS = -F --project-root $(TESTS_DIR) --no-failures-allowed
INFERPRINT_OPTIONS = --issues-tests INFERPRINT_OPTIONS = --issues-tests
SOURCES = \ SOURCES = \

Loading…
Cancel
Save