Skip to content

Commit

Permalink
depr(Arg.rs): adds deprecations in prep for v3
Browse files Browse the repository at this point in the history
A full list of deprecations is:

* Arg::last -> ArgSettings::Last
* Arg::required -> ArgSettings::Required
* Arg::require_equals -> ArgSettings::RequireEquals
* Arg::allow_hyphen_values -> ArgSettings::AllowHyphenValues
* Arg::takes_value -> ArgSettings::TakesValue
* Arg::hide_possible_values -> ArgSettings::HidePossibleValues
* Arg::hide_default_value -> ArgSettings::HideDefaultValue
* Arg::multiple -> ArgSettings::Multiple (see Arg::multiple split)
* Arg::multiple -> ArgSettings::MultipleValues (see Arg::multiple split)
* Arg::multiple -> ArgSettings::MultipleOccurrences (see Arg::multiple split)
* Arg::global -> ArgSettings::Global
* Arg::empty_values -> ArgSettings::AllowEmptyValues
* Arg::hidden -> ArgSettings::Hidden
* Arg::case_insensitive -> ArgSettings::IgnoreCase
* Arg::use_delimiter -> ArgSettings::UseDelimiter
* Arg::require_delimiter -> ArgSettings::RequireDelimiter
* Arg::hide_env_values -> ArgSettings::HideEnvValues
* Arg::next_line_help -> ArgSettings::NextLineHelp
* Arg::set -> Arg::unset_setting (consistent naming with App)
* Arg::unset -> Arg::setting (consistent naming with App)

Relates to #1037
  • Loading branch information
kbknapp committed Jan 31, 2018
1 parent e1f1b47 commit cfd0cc6
Show file tree
Hide file tree
Showing 4 changed files with 1,096 additions and 983 deletions.
8 changes: 4 additions & 4 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ where
if help_help {
let mut pb = Arg::with_name("subcommand")
.index(1)
.set(ArgSettings::Multiple)
.setting(ArgSettings::Multiple)
.help("The subcommand whose help message to display");
pb._build();
parser.positionals.insert(1, pb.name);
Expand Down Expand Up @@ -754,11 +754,11 @@ where
let arg_allows_tac = match needs_val_of {
ParseResult::Opt(name) => {
let o = find!(self.app, &name).expect(INTERNAL_ERROR_MSG);
(o.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings)
(o.is_set(ArgSettings::AllowHyphenValues) || app_wide_settings)
}
ParseResult::Pos(name) => {
let p = find!(self.app, &name).expect(INTERNAL_ERROR_MSG);
(p.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings)
(p.is_set(ArgSettings::AllowHyphenValues) || app_wide_settings)
}
ParseResult::ValuesDone => return true,
_ => false,
Expand Down Expand Up @@ -1061,7 +1061,7 @@ where
debugln!("Parser::parse_opt; opt.settings={:?}", opt.settings);
let mut has_eq = false;
let no_val = val.is_none();
let empty_vals = opt.is_set(ArgSettings::EmptyValues);
let empty_vals = opt.is_set(ArgSettings::AllowEmptyValues);
let min_vals_zero = opt.min_vals.unwrap_or(1) == 0;
let needs_eq = opt.is_set(ArgSettings::RequireEquals);

Expand Down
4 changes: 2 additions & 2 deletions src/app/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<'a, 'b, 'c, 'z> Validator<'a, 'b, 'c, 'z> {
if let Some(ref p_vals) = arg.possible_vals {
debugln!("Validator::validate_arg_values: possible_vals={:?}", p_vals);
let val_str = val.to_string_lossy();
let ok = if arg.is_set(ArgSettings::CaseInsensitive) {
let ok = if arg.is_set(ArgSettings::IgnoreCase) {
p_vals.iter().any(|pv| pv.eq_ignore_ascii_case(&*val_str))
} else {
p_vals.contains(&&*val_str)
Expand All @@ -110,7 +110,7 @@ impl<'a, 'b, 'c, 'z> Validator<'a, 'b, 'c, 'z> {
));
}
}
if !arg.is_set(ArgSettings::EmptyValues) && val.is_empty_()
if !arg.is_set(ArgSettings::AllowEmptyValues) && val.is_empty_()
&& matcher.contains(&*arg.name)
{
debugln!("Validator::validate_arg_values: illegal empty val found");
Expand Down
Loading

0 comments on commit cfd0cc6

Please sign in to comment.