mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
Auto merge of #433 - japaric:rustup, r=kbknapp
rustup: fix nightly See details in the commits.
This commit is contained in:
commit
a5ceee21b5
11 changed files with 26 additions and 23 deletions
|
@ -1,4 +1,5 @@
|
|||
#[doc(hidden)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct AppMeta<'b> {
|
||||
pub name: String,
|
||||
pub bin_name: Option<String>,
|
||||
|
|
|
@ -24,6 +24,7 @@ use osstringext::OsStrExt2;
|
|||
use app::meta::AppMeta;
|
||||
use args::MatchedArg;
|
||||
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[doc(hidden)]
|
||||
pub struct Parser<'a, 'b> where 'a: 'b {
|
||||
required: Vec<&'b str>,
|
||||
|
@ -295,7 +296,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
continue;
|
||||
}
|
||||
if let Some(p) = self.positionals.values().filter(|x| &x.name == &p).next() {
|
||||
pmap.insert(p.index, format!("{}", p));
|
||||
pmap.insert(p.index, p.to_string());
|
||||
}
|
||||
}
|
||||
for (_, s) in pmap {
|
||||
|
@ -307,9 +308,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
if $m.is_some() && $m.as_ref().unwrap().contains(f) {
|
||||
continue;
|
||||
}
|
||||
$r.push_back(format!("{}", $i.filter(|flg| &flg.name == &f)
|
||||
.next()
|
||||
.unwrap()));
|
||||
$r.push_back($i.filter(|flg| &flg.name == &f).next().unwrap().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -427,7 +426,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
debug!("Starts new arg...");
|
||||
let starts_new_arg = if arg_os.starts_with(b"-") {
|
||||
sdebugln!("Yes");
|
||||
!(arg_os.len() == 1)
|
||||
!(arg_os.len_() == 1)
|
||||
} else {
|
||||
sdebugln!("No");
|
||||
false
|
||||
|
@ -448,7 +447,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
}
|
||||
}
|
||||
if arg_os.starts_with(b"--") {
|
||||
if arg_os.len() == 2 {
|
||||
if arg_os.len_() == 2 {
|
||||
// The user has passed '--' which means only positional args follow no matter
|
||||
// what they start with
|
||||
pos_only = true;
|
||||
|
@ -457,7 +456,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
|
||||
needs_val_of = try!(self.parse_long_arg(matcher, &arg_os));
|
||||
continue;
|
||||
} else if arg_os.starts_with(b"-") && arg_os.len() != 1 {
|
||||
} else if arg_os.starts_with(b"-") && arg_os.len_() != 1 {
|
||||
needs_val_of = try!(self.parse_short_arg(matcher, &arg_os));
|
||||
if !(needs_val_of.is_none() && self.is_set(AppSettings::AllowLeadingHyphen)) {
|
||||
continue;
|
||||
|
@ -628,21 +627,21 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
if let Some(f) = self.flags.iter().filter(|f| &f.name == &k).next() {
|
||||
if let Some(ref bl) = f.blacklist {
|
||||
if bl.contains(&name) {
|
||||
return Some(format!("{}", f));
|
||||
return Some(f.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(o) = self.opts.iter().filter(|o| &o.name == &k).next() {
|
||||
if let Some(ref bl) = o.blacklist {
|
||||
if bl.contains(&name) {
|
||||
return Some(format!("{}", o));
|
||||
return Some(o.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(pos) = self.positionals.values().filter(|p| &p.name == &k).next() {
|
||||
if let Some(ref bl) = pos.blacklist {
|
||||
if bl.contains(&name) {
|
||||
return Some(format!("{}", pos));
|
||||
return Some(pos.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -972,7 +971,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
debug!("Checking for val...");
|
||||
if let Some(fv) = val {
|
||||
let v = fv.trim_left_matches(b'=');
|
||||
if !opt.is_set(ArgSettings::EmptyValues) && v.len() == 0 {
|
||||
if !opt.is_set(ArgSettings::EmptyValues) && v.len_() == 0 {
|
||||
sdebugln!("Found Empty - Error");
|
||||
return Err(Error::empty_value(opt, &*self.create_current_usage(matcher)));
|
||||
}
|
||||
|
@ -1043,7 +1042,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
}
|
||||
}
|
||||
if !arg.is_set(ArgSettings::EmptyValues) &&
|
||||
val.is_empty() &&
|
||||
val.is_empty_() &&
|
||||
matcher.contains(&*arg.name()) {
|
||||
return Err(Error::empty_value(arg, &*self.create_current_usage(matcher)));
|
||||
}
|
||||
|
|
|
@ -1842,7 +1842,7 @@ impl<'a, 'b, 'z> From<&'z Arg<'a, 'b>>
|
|||
group: a.group,
|
||||
validator: a.validator.clone(),
|
||||
overrides: a.overrides.clone(),
|
||||
settings: a.settings.clone(),
|
||||
settings: a.settings,
|
||||
val_delim: a.val_delim,
|
||||
default_val: a.default_val,
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ impl<'a, 'b, 'z> From<&'z Arg<'a, 'b>> for FlagBuilder<'a, 'b> {
|
|||
blacklist: a.blacklist.clone(),
|
||||
overrides: a.overrides.clone(),
|
||||
requires: a.requires.clone(),
|
||||
settings: a.settings.clone(),
|
||||
settings: a.settings,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ impl<'n, 'e> OptBuilder<'n, 'e> {
|
|||
overrides: a.overrides.clone(),
|
||||
requires: a.requires.clone(),
|
||||
possible_vals: a.possible_vals.clone(),
|
||||
settings: a.settings.clone(),
|
||||
settings: a.settings,
|
||||
default_val: a.default_val,
|
||||
..Default::default()
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ impl<'n, 'e> PosBuilder<'n, 'e> {
|
|||
possible_vals: a.possible_vals.clone(),
|
||||
help: a.help,
|
||||
val_delim: a.val_delim,
|
||||
settings: a.settings.clone(),
|
||||
settings: a.settings,
|
||||
default_val: a.default_val,
|
||||
..Default::default()
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ use args::settings::ArgSettings;
|
|||
use args::AnyArg;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct ArgMatcher<'a>(pub ArgMatches<'a>);
|
||||
|
||||
impl<'a> ArgMatcher<'a> {
|
||||
|
|
|
@ -496,6 +496,7 @@ impl<'a> ArgMatches<'a> {
|
|||
// license: MIT - Copyright (c) 2015 The Rust Project Developers
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Values<'a> {
|
||||
iter: Map<vec_map::Values<'a, OsString>, fn(&'a OsString) -> &'a str>
|
||||
}
|
||||
|
@ -559,6 +560,7 @@ impl<'a, V> DoubleEndedIterator for Iter<'a, V> {
|
|||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct OsValues<'a> {
|
||||
iter: Map<vec_map::Values<'a, OsString>, fn(&'a OsString) -> &'a OsStr>
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ bitflags! {
|
|||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct ArgFlags(Flags);
|
||||
|
||||
impl ArgFlags {
|
||||
|
|
|
@ -17,9 +17,9 @@ pub trait OsStrExt2 {
|
|||
fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
|
||||
fn split_at(&self, i: usize) -> (&OsStr, &OsStr);
|
||||
fn trim_left_matches(&self, b: u8) -> &OsStr;
|
||||
fn len(&self) -> usize;
|
||||
fn len_(&self) -> usize;
|
||||
fn contains_byte(&self, b: u8) -> bool;
|
||||
fn is_empty(&self) -> bool;
|
||||
fn is_empty_(&self) -> bool;
|
||||
fn split(&self, b: u8) -> OsSplit;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ impl OsStrExt2 for OsStr {
|
|||
self.as_bytes().starts_with(s)
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
fn is_empty_(&self) -> bool {
|
||||
self.as_bytes().is_empty()
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ impl OsStrExt2 for OsStr {
|
|||
for (i, b) in self.as_bytes().iter().enumerate() {
|
||||
if b == &byte { return (&OsStr::from_bytes(&self.as_bytes()[..i]), &OsStr::from_bytes(&self.as_bytes()[i+1..])); }
|
||||
}
|
||||
(&*self, &OsStr::from_bytes(&self.as_bytes()[self.len()..self.len()]))
|
||||
(&*self, &OsStr::from_bytes(&self.as_bytes()[self.len_()..self.len_()]))
|
||||
}
|
||||
|
||||
fn trim_left_matches(&self, byte: u8) -> &OsStr {
|
||||
|
@ -68,7 +68,7 @@ impl OsStrExt2 for OsStr {
|
|||
(&OsStr::from_bytes(&self.as_bytes()[..i]), &OsStr::from_bytes(&self.as_bytes()[i..]))
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
fn len_(&self) -> usize {
|
||||
self.as_bytes().len()
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ pub fn did_you_mean_suffix<'z, T, I>(arg: &str,
|
|||
let mut suffix = "\n\tDid you mean ".to_owned();
|
||||
match style {
|
||||
DidYouMeanMessageStyle::LongFlag =>
|
||||
suffix.push_str(&*format!("{}", Format::Good("--"))),
|
||||
suffix.push_str(&Format::Good("--").to_string()),
|
||||
DidYouMeanMessageStyle::EnumValue => suffix.push('\''),
|
||||
}
|
||||
suffix.push_str(&Format::Good(candidate).to_string()[..]);
|
||||
|
|
Loading…
Add table
Reference in a new issue