Skip to content

Commit

Permalink
Write non-output to stderr when there is output
Browse files Browse the repository at this point in the history
  • Loading branch information
solidsnack committed Mar 11, 2016
1 parent 9302963 commit d216c35
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/bin/rustfmt.rs
Expand Up @@ -28,6 +28,15 @@ use std::str::FromStr;

use getopts::{Matches, Options};

macro_rules! msg(
($($arg:tt)*) => (
match writeln!(&mut ::std::io::stderr(), $($arg)* ) {
Ok(_) => {},
Err(x) => panic!("Unable to write to stderr: {}", x),
}
)
);

/// Rustfmt operations.
enum Operation {
/// Format files and their child modules.
Expand Down Expand Up @@ -203,7 +212,7 @@ fn execute() -> i32 {
path = path_tmp;
};
if let Some(path) = path.as_ref() {
println!("Using rustfmt config file {}", path.display());
msg!("Using rustfmt config file {}", path.display());
}
for file in files {
// Check the file directory if the config-path could not be read or not provided
Expand All @@ -213,7 +222,7 @@ fn execute() -> i32 {
for {}",
file.display()));
if let Some(path) = path_tmp.as_ref() {
println!("Using rustfmt config file {} for {}",
msg!("Using rustfmt config file {} for {}",
path.display(),
file.display());
}
Expand Down

0 comments on commit d216c35

Please sign in to comment.