mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Merge branch 'master' of github.com:kbknapp/clap-rs
This commit is contained in:
commit
2a09c662a3
2 changed files with 11 additions and 11 deletions
10
src/app.rs
10
src/app.rs
|
@ -1711,7 +1711,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
|
|||
if num == vals.len() as u8 && !opt.multiple {
|
||||
self.report_error(format!("The argument '{}' was found, \
|
||||
but '{}' only expects {} values",
|
||||
Format::Warning(&arg),
|
||||
Format::Warning(arg.as_ref()),
|
||||
Format::Warning(opt.to_string()),
|
||||
Format::Good(vals.len().to_string())),
|
||||
true,
|
||||
|
@ -1814,7 +1814,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
|
|||
format!("The subcommand '{}' isn't valid\n\tDid you mean '{}' ?\n\n\
|
||||
If you received this message in error, try \
|
||||
re-running with '{} {} {}'",
|
||||
Format::Warning(&arg),
|
||||
Format::Warning(arg.as_ref()),
|
||||
Format::Good(candidate_subcommand),
|
||||
self.bin_name.clone().unwrap_or(self.name.clone()),
|
||||
Format::Good("--"),
|
||||
|
@ -1827,7 +1827,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
|
|||
if self.positionals_idx.is_empty() {
|
||||
self.report_error(
|
||||
format!("Found argument '{}', but {} wasn't expecting any",
|
||||
Format::Warning(&arg),
|
||||
Format::Warning(arg.as_ref()),
|
||||
self.bin_name.clone().unwrap_or(self.name.clone())),
|
||||
true,
|
||||
Some(matches.args.keys().map(|k| *k).collect()));
|
||||
|
@ -1866,7 +1866,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
|
|||
if vals.len() as u8 == num {
|
||||
self.report_error(format!("The argument '{}' was found, \
|
||||
but '{}' wasn't expecting any more values",
|
||||
Format::Warning(&arg),
|
||||
Format::Warning(arg.as_ref()),
|
||||
Format::Warning(p.to_string())),
|
||||
true,
|
||||
Some(matches.args.keys()
|
||||
|
@ -1935,7 +1935,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
|
|||
|
||||
} else {
|
||||
self.report_error(format!("The argument '{}' was found, but '{}' wasn't \
|
||||
expecting any", Format::Warning(&arg),
|
||||
expecting any", Format::Warning(arg.as_ref()),
|
||||
self.bin_name.clone().unwrap_or(self.name.clone())),
|
||||
true,
|
||||
Some(matches.args.keys().map(|k| *k).collect()));
|
||||
|
|
12
src/fmt.rs
12
src/fmt.rs
|
@ -1,8 +1,8 @@
|
|||
use std::fmt;
|
||||
|
||||
#[cfg(feature = "color")]
|
||||
#[cfg(all(feature = "color", not(target_os = "windows")))]
|
||||
use ansi_term::Colour::{Red, Green, Yellow};
|
||||
#[cfg(feature = "color")]
|
||||
#[cfg(all(feature = "color", not(target_os = "windows")))]
|
||||
use ansi_term::ANSIString;
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub enum Format<T> {
|
|||
Good(T),
|
||||
}
|
||||
|
||||
#[cfg(feature = "color")]
|
||||
#[cfg(all(feature = "color", not(target_os = "windows")))]
|
||||
impl<T: AsRef<str>> Format<T> {
|
||||
fn format(&self) -> ANSIString {
|
||||
match *self {
|
||||
|
@ -24,14 +24,14 @@ impl<T: AsRef<str>> Format<T> {
|
|||
|
||||
}
|
||||
|
||||
#[cfg(feature = "color")]
|
||||
#[cfg(all(feature = "color", not(target_os = "windows")))]
|
||||
impl<T: AsRef<str>> fmt::Display for Format<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", &self.format())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "color"))]
|
||||
#[cfg(any(not(feature = "color"), target_os = "windows"))]
|
||||
impl<T: fmt::Display> Format<T> {
|
||||
fn format(&self) -> &T {
|
||||
match *self {
|
||||
|
@ -42,7 +42,7 @@ impl<T: fmt::Display> Format<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "color"))]
|
||||
#[cfg(any(not(feature = "color"), target_os = "windows"))]
|
||||
impl<T: fmt::Display> fmt::Display for Format<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", &self.format())
|
||||
|
|
Loading…
Reference in a new issue