Merge branch 'master' of github.com:kbknapp/clap-rs

This commit is contained in:
Kevin K 2015-07-18 11:03:15 -04:00
commit 2a09c662a3
2 changed files with 11 additions and 11 deletions

View file

@ -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 { if num == vals.len() as u8 && !opt.multiple {
self.report_error(format!("The argument '{}' was found, \ self.report_error(format!("The argument '{}' was found, \
but '{}' only expects {} values", but '{}' only expects {} values",
Format::Warning(&arg), Format::Warning(arg.as_ref()),
Format::Warning(opt.to_string()), Format::Warning(opt.to_string()),
Format::Good(vals.len().to_string())), Format::Good(vals.len().to_string())),
true, 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\ format!("The subcommand '{}' isn't valid\n\tDid you mean '{}' ?\n\n\
If you received this message in error, try \ If you received this message in error, try \
re-running with '{} {} {}'", re-running with '{} {} {}'",
Format::Warning(&arg), Format::Warning(arg.as_ref()),
Format::Good(candidate_subcommand), Format::Good(candidate_subcommand),
self.bin_name.clone().unwrap_or(self.name.clone()), self.bin_name.clone().unwrap_or(self.name.clone()),
Format::Good("--"), 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() { if self.positionals_idx.is_empty() {
self.report_error( self.report_error(
format!("Found argument '{}', but {} wasn't expecting any", 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())), self.bin_name.clone().unwrap_or(self.name.clone())),
true, true,
Some(matches.args.keys().map(|k| *k).collect())); 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 { if vals.len() as u8 == num {
self.report_error(format!("The argument '{}' was found, \ self.report_error(format!("The argument '{}' was found, \
but '{}' wasn't expecting any more values", but '{}' wasn't expecting any more values",
Format::Warning(&arg), Format::Warning(arg.as_ref()),
Format::Warning(p.to_string())), Format::Warning(p.to_string())),
true, true,
Some(matches.args.keys() Some(matches.args.keys()
@ -1935,7 +1935,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
} else { } else {
self.report_error(format!("The argument '{}' was found, but '{}' wasn't \ 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())), self.bin_name.clone().unwrap_or(self.name.clone())),
true, true,
Some(matches.args.keys().map(|k| *k).collect())); Some(matches.args.keys().map(|k| *k).collect()));

View file

@ -1,8 +1,8 @@
use std::fmt; use std::fmt;
#[cfg(feature = "color")] #[cfg(all(feature = "color", not(target_os = "windows")))]
use ansi_term::Colour::{Red, Green, Yellow}; use ansi_term::Colour::{Red, Green, Yellow};
#[cfg(feature = "color")] #[cfg(all(feature = "color", not(target_os = "windows")))]
use ansi_term::ANSIString; use ansi_term::ANSIString;
@ -12,7 +12,7 @@ pub enum Format<T> {
Good(T), Good(T),
} }
#[cfg(feature = "color")] #[cfg(all(feature = "color", not(target_os = "windows")))]
impl<T: AsRef<str>> Format<T> { impl<T: AsRef<str>> Format<T> {
fn format(&self) -> ANSIString { fn format(&self) -> ANSIString {
match *self { 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> { impl<T: AsRef<str>> fmt::Display for Format<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", &self.format()) write!(f, "{}", &self.format())
} }
} }
#[cfg(not(feature = "color"))] #[cfg(any(not(feature = "color"), target_os = "windows"))]
impl<T: fmt::Display> Format<T> { impl<T: fmt::Display> Format<T> {
fn format(&self) -> &T { fn format(&self) -> &T {
match *self { 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> { impl<T: fmt::Display> fmt::Display for Format<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", &self.format()) write!(f, "{}", &self.format())