From 9cb5dceb3e5fe5e0e7b24619ff77e5040672b723 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Sat, 18 Jul 2015 14:31:09 -0400 Subject: [PATCH] fix: fixes formatting bug which prevented compiling on windows Closes #163 --- src/app.rs | 10 +++++----- src/fmt.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/app.rs b/src/app.rs index ec88ee1ac3c..e65f9e1d81b 100644 --- a/src/app.rs +++ b/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())); diff --git a/src/fmt.rs b/src/fmt.rs index 1d46509604b..14b45c0b815 100644 --- a/src/fmt.rs +++ b/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 { Good(T), } -#[cfg(feature = "color")] +#[cfg(all(feature = "color", not(target_os = "windows")))] impl> Format { fn format(&self) -> ANSIString { match *self { @@ -24,14 +24,14 @@ impl> Format { } -#[cfg(feature = "color")] +#[cfg(all(feature = "color", not(target_os = "windows")))] impl> fmt::Display for Format { 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 Format { fn format(&self) -> &T { match *self { @@ -42,7 +42,7 @@ impl Format { } } -#[cfg(not(feature = "color"))] +#[cfg(any(not(feature = "color"), target_os = "windows"))] impl fmt::Display for Format { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", &self.format())