[CLOpt] remove `accept_unknown` optional argument of `parse`

Summary: Also updated the doc comment of `parse`, it had gone a bit out of sync.

Reviewed By: jberdine

Differential Revision: D4435580

fbshipit-source-id: bb1a6f2
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent ebc4c6fd53
commit 4b45d5d8a0

@ -594,8 +594,7 @@ let extra_env_args = ref []
let extend_env_args args = let extend_env_args args =
extra_env_args := List.rev_append args !extra_env_args extra_env_args := List.rev_append args !extra_env_args
let parse ?(incomplete=false) ?(accept_unknown=false) ?config_file current_exe exe_usage let parse ?(incomplete=false) ?config_file current_exe exe_usage ~should_parse_cl_args =
~should_parse_cl_args =
let full_speclist = ref [] let full_speclist = ref []
in in
let usage_msg = exe_usage current_exe let usage_msg = exe_usage current_exe
@ -707,7 +706,7 @@ let parse ?(incomplete=false) ?(accept_unknown=false) ?config_file current_exe e
arg_being_parsed := 0; arg_being_parsed := 0;
(* tests if msg indicates an unknown option, as opposed to a known option with bad argument *) (* tests if msg indicates an unknown option, as opposed to a known option with bad argument *)
let is_unknown msg = String.is_substring msg ~substring:": unknown option" in let is_unknown msg = String.is_substring msg ~substring:": unknown option" in
accept_unknown_args := accept_unknown ; accept_unknown_args := false ;
let rec parse_loop () = let rec parse_loop () =
try try
Arg.parse_argv_dynamic ~current:arg_being_parsed !args_to_parse curr_speclist Arg.parse_argv_dynamic ~current:arg_being_parsed !args_to_parse curr_speclist

@ -147,18 +147,23 @@ val env_var_sep : char
(** [extend_env_args args] appends [args] to those passed via [args_env_var] *) (** [extend_env_args args] appends [args] to those passed via [args_env_var] *)
val extend_env_args : string list -> unit val extend_env_args : string list -> unit
(** [parse env_var exe_usage exe] parses command line arguments as specified by preceding calls to (** [parse exe exe_usage exe] parses command line arguments as specified by preceding calls to the
the [mk_*] functions, and returns a function that prints the usage message and help text then [mk_*] functions, and returns a function that prints the usage message and help text then exits.
exits. [exe] is used to construct the help message appropriate for that executable. The decoded
values of the inferconfig file [config_file], if provided, and of the environment variable [exe] is used to construct the help message appropriate for that executable.
[env_var] are prepended to [Sys.argv] before parsing. Therefore arguments passed on the command
line supersede those specified in the environment variable, which themselves supersede those The decoded values of the inferconfig file [config_file], if provided, are parsed, followed by
passed via the config file. WARNING: An argument will be interpreted as many times as it the decoded values of the environment variable [args_env_var], followed by [Sys.argv] if
appears in all of the config file, the environment variable, and the command line. The [env_var] [should_parse_cl_args] is true. Therefore arguments passed on the command line supersede those
is set to the full set of options parsed. If [incomplete] is set, unknown options are ignored, specified in the environment variable, which themselves supersede those passed via the config
and [env_var] is not set. If [accept_unknown] is set, unknown options are treated the same as file.
anonymous arguments. *)
val parse : ?incomplete:bool -> ?accept_unknown:bool -> ?config_file:string -> If [incomplete] is set, unknown options are ignored, and [args_env_var] is not set.
WARNING: An argument will be interpreted as many times as it appears in all of the config file,
the environment variable, and the command line. The [args_env_var] is set to the full set of
options parsed. *)
val parse : ?incomplete:bool -> ?config_file:string ->
exe -> (exe -> Arg.usage_msg) -> should_parse_cl_args:bool -> (int -> 'a) exe -> (exe -> Arg.usage_msg) -> should_parse_cl_args:bool -> (int -> 'a)
(** [is_env_var_set var] is true if $[var]=1 *) (** [is_env_var_set var] is true if $[var]=1 *)

Loading…
Cancel
Save