Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into env-literal
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Aug 10, 2021
2 parents 20eef74 + 6527fde commit b11408e
Show file tree
Hide file tree
Showing 7 changed files with 583 additions and 337 deletions.
21 changes: 0 additions & 21 deletions src/build/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,10 @@ impl_settings! { AppSettings, AppFlags,
=> Flags::DISABLE_VERSION_FOR_SC,
WaitOnError("waitonerror")
=> Flags::WAIT_ON_ERROR,
TrailingValues("trailingvalues")
=> Flags::TRAILING_VALUES,
Built("built")
=> Flags::BUILT,
BinNameBuilt("binnamebuilt")
=> Flags::BIN_NAME_BUILT,
ValidArgFound("validargfound")
=> Flags::VALID_ARG_FOUND,
InferSubcommands("infersubcommands")
=> Flags::INFER_SUBCOMMANDS,
AllArgsOverrideSelf("allargsoverrideself")
Expand Down Expand Up @@ -1099,22 +1095,13 @@ pub enum AppSettings {
/// @TODO-v3: @docs write them...maybe rename
NoAutoVersion,

#[doc(hidden)]
/// If the user already passed '--'. Meaning only positional args follow.
TrailingValues,

#[doc(hidden)]
/// If the app is already built, used for caching.
Built,

#[doc(hidden)]
/// If the app's bin name is already built, used for caching.
BinNameBuilt,

#[doc(hidden)]
/// This is paired with `ArgsNegateSubcommands`. Used to determine if we
/// already met any valid arg(then we shouldn't expect subcommands after it).
ValidArgFound,
}

#[cfg(test)]
Expand Down Expand Up @@ -1258,19 +1245,11 @@ mod test {
"waitonerror".parse::<AppSettings>().unwrap(),
AppSettings::WaitOnError
);
assert_eq!(
"validargfound".parse::<AppSettings>().unwrap(),
AppSettings::ValidArgFound
);
assert_eq!("built".parse::<AppSettings>().unwrap(), AppSettings::Built);
assert_eq!(
"binnamebuilt".parse::<AppSettings>().unwrap(),
AppSettings::BinNameBuilt
);
assert_eq!(
"trailingvalues".parse::<AppSettings>().unwrap(),
AppSettings::TrailingValues
);
assert_eq!(
"infersubcommands".parse::<AppSettings>().unwrap(),
AppSettings::InferSubcommands
Expand Down
9 changes: 4 additions & 5 deletions src/parse/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,8 @@ impl Error {
}
}

pub(crate) fn no_equals(arg: &Arg, usage: String, color: ColorChoice) -> Self {
pub(crate) fn no_equals(arg: String, usage: String, color: ColorChoice) -> Self {
let mut c = Colorizer::new(true, color);
let arg = arg.to_string();

start_error(&mut c, "Equal sign is needed when assigning values to '");
c.warning(&arg);
Expand Down Expand Up @@ -798,7 +797,7 @@ impl Error {

pub(crate) fn too_many_values(
val: String,
arg: &Arg,
arg: String,
usage: String,
color: ColorChoice,
) -> Self {
Expand All @@ -807,15 +806,15 @@ impl Error {
start_error(&mut c, "The value '");
c.warning(val.clone());
c.none("' was provided to '");
c.warning(arg.to_string());
c.warning(&arg);
c.none("' but it wasn't expecting any more values");
put_usage(&mut c, usage);
try_help(&mut c);

Error {
message: c,
kind: ErrorKind::TooManyValues,
info: vec![arg.to_string(), val],
info: vec![arg, val],
source: None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod validator;
pub(crate) use self::{
arg_matcher::ArgMatcher,
matches::{MatchedArg, SubCommand, ValueType},
parser::{Input, ParseResult, Parser},
parser::{Input, ParseState, Parser},
validator::Validator,
};

Expand Down
Loading

0 comments on commit b11408e

Please sign in to comment.