mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 14:54:15 +00:00
style: Clippy
This commit is contained in:
parent
c638330e85
commit
3722270e47
3 changed files with 39 additions and 39 deletions
|
@ -680,8 +680,8 @@ impl<'help> App<'help> {
|
|||
|
||||
let mut c = Colorizer::new(false, color);
|
||||
let parser = Parser::new(self);
|
||||
let usage = Usage::new(&parser.app, &parser.required);
|
||||
Help::new(HelpWriter::Buffer(&mut c), &parser.app, &usage, false).write_help()?;
|
||||
let usage = Usage::new(parser.app, &parser.required);
|
||||
Help::new(HelpWriter::Buffer(&mut c), parser.app, &usage, false).write_help()?;
|
||||
c.print()
|
||||
}
|
||||
|
||||
|
@ -706,8 +706,8 @@ impl<'help> App<'help> {
|
|||
|
||||
let mut c = Colorizer::new(false, color);
|
||||
let parser = Parser::new(self);
|
||||
let usage = Usage::new(&parser.app, &parser.required);
|
||||
Help::new(HelpWriter::Buffer(&mut c), &parser.app, &usage, true).write_help()?;
|
||||
let usage = Usage::new(parser.app, &parser.required);
|
||||
Help::new(HelpWriter::Buffer(&mut c), parser.app, &usage, true).write_help()?;
|
||||
c.print()
|
||||
}
|
||||
|
||||
|
@ -731,8 +731,8 @@ impl<'help> App<'help> {
|
|||
self._build();
|
||||
|
||||
let parser = Parser::new(self);
|
||||
let usage = Usage::new(&parser.app, &parser.required);
|
||||
Help::new(HelpWriter::Normal(w), &parser.app, &usage, false).write_help()?;
|
||||
let usage = Usage::new(parser.app, &parser.required);
|
||||
Help::new(HelpWriter::Normal(w), parser.app, &usage, false).write_help()?;
|
||||
w.flush()
|
||||
}
|
||||
|
||||
|
@ -756,8 +756,8 @@ impl<'help> App<'help> {
|
|||
self._build();
|
||||
|
||||
let parser = Parser::new(self);
|
||||
let usage = Usage::new(&parser.app, &parser.required);
|
||||
Help::new(HelpWriter::Normal(w), &parser.app, &usage, true).write_help()?;
|
||||
let usage = Usage::new(parser.app, &parser.required);
|
||||
Help::new(HelpWriter::Normal(w), parser.app, &usage, true).write_help()?;
|
||||
w.flush()
|
||||
}
|
||||
|
||||
|
@ -825,7 +825,7 @@ impl<'help> App<'help> {
|
|||
self._build();
|
||||
|
||||
let parser = Parser::new(self);
|
||||
Usage::new(&parser.app, &parser.required).create_usage_with_title(&[])
|
||||
Usage::new(parser.app, &parser.required).create_usage_with_title(&[])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
return Err(ClapError::no_equals(
|
||||
self.app,
|
||||
arg,
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
ParseResult::NoMatchingArg { arg } => {
|
||||
|
@ -272,7 +272,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
self.app,
|
||||
rest,
|
||||
arg,
|
||||
Usage::new(&self.app, &self.required).create_usage_no_title(&used),
|
||||
Usage::new(self.app, &self.required).create_usage_no_title(&used),
|
||||
))
|
||||
}
|
||||
ParseResult::HelpFlag => {
|
||||
|
@ -346,7 +346,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
return Err(ClapError::no_equals(
|
||||
self.app,
|
||||
arg,
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
))
|
||||
}
|
||||
ParseResult::NoMatchingArg { arg } => {
|
||||
|
@ -354,7 +354,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
self.app,
|
||||
arg,
|
||||
None,
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
ParseResult::HelpFlag => {
|
||||
|
@ -399,7 +399,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
self.app,
|
||||
arg_os.to_str_lossy().into_owned(),
|
||||
None,
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -440,7 +440,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
None => {
|
||||
return Err(ClapError::invalid_utf8(
|
||||
self.app,
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
};
|
||||
|
@ -454,7 +454,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
if !allow_invalid_utf8 && v.to_str().is_none() {
|
||||
return Err(ClapError::invalid_utf8(
|
||||
self.app,
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
sc_m.add_val_to(
|
||||
|
@ -499,7 +499,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
return Err(ClapError::missing_subcommand(
|
||||
self.app,
|
||||
bn.to_string(),
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
));
|
||||
} else if self.is_set(AS::SubcommandRequiredElseHelp) {
|
||||
debug!("Parser::get_matches_with: SubcommandRequiredElseHelp=true");
|
||||
|
@ -527,7 +527,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
return ClapError::unnecessary_double_dash(
|
||||
self.app,
|
||||
arg_os.to_str_lossy().into_owned(),
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
.as_ref()
|
||||
.unwrap_or(&self.app.name)
|
||||
.to_string(),
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
);
|
||||
}
|
||||
// If the argument must be a subcommand.
|
||||
|
@ -567,7 +567,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
self.app,
|
||||
arg_os.to_str_lossy().into_owned(),
|
||||
None,
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&[]),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
|
||||
if !self.is_set(AS::SubcommandsNegateReqs) {
|
||||
let reqs =
|
||||
Usage::new(&self.app, &self.required).get_required_usage_from(&[], None, true); // maybe Some(m)
|
||||
Usage::new(self.app, &self.required).get_required_usage_from(&[], None, true); // maybe Some(m)
|
||||
|
||||
for s in &reqs {
|
||||
mid_string.push_str(s);
|
||||
|
@ -1557,14 +1557,14 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
self.app,
|
||||
format!("--{}", arg),
|
||||
did_you_mean,
|
||||
Usage::new(&self.app, &self.required).create_usage_with_title(&*used),
|
||||
Usage::new(self.app, &self.required).create_usage_with_title(&*used),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn write_help_err(&self) -> ClapResult<Colorizer> {
|
||||
let usage = Usage::new(&self.app, &self.required);
|
||||
let usage = Usage::new(self.app, &self.required);
|
||||
let mut c = Colorizer::new(true, self.color_help());
|
||||
Help::new(HelpWriter::Buffer(&mut c), &self.app, &usage, false).write_help()?;
|
||||
Help::new(HelpWriter::Buffer(&mut c), self.app, &usage, false).write_help()?;
|
||||
Ok(c)
|
||||
}
|
||||
|
||||
|
@ -1575,10 +1575,10 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
);
|
||||
|
||||
use_long = use_long && self.use_long_help();
|
||||
let usage = Usage::new(&self.app, &self.required);
|
||||
let usage = Usage::new(self.app, &self.required);
|
||||
let mut c = Colorizer::new(false, self.color_help());
|
||||
|
||||
match Help::new(HelpWriter::Buffer(&mut c), &self.app, &usage, use_long).write_help() {
|
||||
match Help::new(HelpWriter::Buffer(&mut c), self.app, &usage, use_long).write_help() {
|
||||
Err(e) => e.into(),
|
||||
_ => ClapError::for_app(self.app, c, ErrorKind::DisplayHelp, vec![]),
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
return Err(Error::empty_value(
|
||||
self.p.app,
|
||||
o,
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
);
|
||||
return Err(Error::invalid_utf8(
|
||||
self.p.app,
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
if !arg.possible_vals.is_empty() {
|
||||
|
@ -122,7 +122,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
.filter_map(PossibleValue::get_visible_name)
|
||||
.collect::<Vec<_>>(),
|
||||
arg,
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&used),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&used),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
return Err(Error::empty_value(
|
||||
self.p.app,
|
||||
arg,
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
self.p.app,
|
||||
arg,
|
||||
Vec::new(),
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
))
|
||||
})
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
.chain(used_filtered.iter())
|
||||
.cloned()
|
||||
.collect();
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&required)
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&required)
|
||||
}
|
||||
|
||||
fn gather_requirements(&mut self, matcher: &ArgMatcher) {
|
||||
|
@ -317,7 +317,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
return Err(Error::unexpected_multiple_usage(
|
||||
self.p.app,
|
||||
a,
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
if let Some(max_occurs) = a.max_occurs {
|
||||
|
@ -332,7 +332,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
a,
|
||||
max_occurs,
|
||||
occurs,
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
} else {
|
||||
total_num
|
||||
},
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
.expect(INVALID_UTF8)
|
||||
.to_string(),
|
||||
a.to_string(),
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
a,
|
||||
num,
|
||||
ma.num_vals(),
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
num == 0
|
||||
|
@ -404,7 +404,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
return Err(Error::empty_value(
|
||||
self.p.app,
|
||||
a,
|
||||
Usage::new(&self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
Usage::new(self.p.app, &self.p.required).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
|
@ -514,7 +514,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
self.p.required
|
||||
);
|
||||
|
||||
let usg = Usage::new(&self.p.app, &self.p.required);
|
||||
let usg = Usage::new(self.p.app, &self.p.required);
|
||||
|
||||
let req_args = usg.get_required_usage_from(&incl, Some(matcher), true);
|
||||
|
||||
|
|
Loading…
Reference in a new issue