Clean up command line argument filtering.

master
Rohan Jacob-Rao 10 years ago
parent 9b3f291b99
commit 9643bdb1c6

@ -787,6 +787,12 @@ let filename_to_relative root fname =
remainder remainder
(* Type of command-line arguments before processing *)
type arg_list = (string * Arg.spec * string option * string) list
let arg_desc_filter options_to_keep =
list_filter (function (option_name, _, _, _) -> list_mem string_equal option_name options_to_keep)
let base_arg_desc = let base_arg_desc =
[ [
"-results_dir", "-results_dir",

@ -388,11 +388,17 @@ val do_outf : outfile option ref -> (outfile -> unit) -> unit
(** close an outfile *) (** close an outfile *)
val close_outf : outfile -> unit val close_outf : outfile -> unit
(* Type of command-line arguments before processing *)
type arg_list = (string * Arg.spec * string option * string) list
(* Filter arguments by name, i.e. keep those whose name appears in the name list *)
val arg_desc_filter : string list -> arg_list -> arg_list
(** Basic command-line arguments *) (** Basic command-line arguments *)
val base_arg_desc : (string * Arg.spec * string option * string) list val base_arg_desc : arg_list
(** Reserved command-line arguments *) (** Reserved command-line arguments *)
val reserved_arg_desc : (string * Arg.spec * string option * string) list val reserved_arg_desc : arg_list
(** Escape a string for use in a CSV or XML file: replace reserved characters with escape sequences *) (** Escape a string for use in a CSV or XML file: replace reserved characters with escape sequences *)
module Escape : sig module Escape : sig

@ -16,13 +16,9 @@ module L = Logging
open CFrontend_utils open CFrontend_utils
let arg_desc = let arg_desc =
let base_arg =
let options_to_keep = ["-results_dir"] in
Config.dotty_cfg_libs := false; (* default behavior for this frontend *) Config.dotty_cfg_libs := false; (* default behavior for this frontend *)
let filter arg_desc =
List.filter (fun desc -> let (option_name, _, _, _) = desc in List.mem option_name options_to_keep) arg_desc in
let desc = let desc =
(filter Utils.base_arg_desc) @ (Utils.arg_desc_filter ["-results_dir"] Utils.base_arg_desc) @
[ [
"-c", "-c",
Arg.String (fun cfile -> CFrontend_config.source_file := Some cfile), Arg.String (fun cfile -> CFrontend_config.source_file := Some cfile),
@ -74,8 +70,7 @@ let arg_desc =
None, None,
"Mode for computing the models"; "Mode for computing the models";
] in ] in
Utils.Arg2.create_options_desc false "Parsing Options" desc in Utils.Arg2.create_options_desc false "Parsing Options" desc
base_arg
let usage = let usage =
"\nUsage: InferClang -c C Files -ast AST Files -results_dir <output-dir> [options] \n" "\nUsage: InferClang -c C Files -ast AST Files -results_dir <output-dir> [options] \n"

@ -14,12 +14,9 @@ module L = Logging
open Utils open Utils
let arg_desc = let arg_desc =
let base_arg =
let options_to_keep = ["-results_dir"; "-project_root"] in let options_to_keep = ["-results_dir"; "-project_root"] in
let filter arg_desc =
list_filter (fun desc -> let (option_name, _, _, _) = desc in list_mem string_equal option_name options_to_keep) arg_desc in
let desc = let desc =
(filter base_arg_desc) @ (arg_desc_filter options_to_keep base_arg_desc) @
[ [
"-models", Arg.String (fun filename -> JClasspath.add_models filename), Some "paths", "set the path to the jar containing the models"; "-models", Arg.String (fun filename -> JClasspath.add_models filename), Some "paths", "set the path to the jar containing the models";
"-debug", Arg.Unit (fun () -> JConfig.debug_mode := true), None, "write extra translation information"; "-debug", Arg.Unit (fun () -> JConfig.debug_mode := true), None, "write extra translation information";
@ -30,8 +27,7 @@ let arg_desc =
"-verbose_out", Arg.String (fun path -> JClasspath.set_verbose_out path), None, "-verbose_out", Arg.String (fun path -> JClasspath.set_verbose_out path), None,
"Set the path to the javac verbose output" "Set the path to the javac verbose output"
] in ] in
Arg2.create_options_desc false "Parsing Options" desc in Arg2.create_options_desc false "Parsing Options" desc
base_arg
let usage = let usage =
"Usage: InferJava -d compilation_dir -sources filename\n" "Usage: InferJava -d compilation_dir -sources filename\n"

@ -10,11 +10,8 @@ open Utils
let arg_desc = let arg_desc =
let options_to_keep = ["-results_dir"; "-project_root"] in let options_to_keep = ["-results_dir"; "-project_root"] in
let filter arg_desc = list_filter
(fun desc -> let (option_name, _, _, _) = desc in list_mem string_equal option_name options_to_keep)
arg_desc in
let desc = let desc =
filter base_arg_desc @ arg_desc_filter options_to_keep base_arg_desc @
[ [
"-c", "-c",
Arg.String (fun cfile -> LConfig.source_filename := Some cfile), Arg.String (fun cfile -> LConfig.source_filename := Some cfile),

Loading…
Cancel
Save