Skip to content

Commit

Permalink
fix: fixes formatting bug which prevented compiling on windows
Browse files Browse the repository at this point in the history
Closes #163
  • Loading branch information
kbknapp committed Jul 18, 2015
1 parent dd6f13d commit 9cb5dce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/app.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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("--"),
Expand All @@ -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()));
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()));
Expand Down
12 changes: 6 additions & 6 deletions 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;


Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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())
Expand Down

0 comments on commit 9cb5dce

Please sign in to comment.