From 1fd1c056534d838416db773f5ca295f4206ceff2 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 18 Aug 2017 14:15:43 -0700 Subject: [PATCH] Retire warn! in favor of eprintln! (#218) --- src/app.rs | 20 ++++++-------------- src/lib.rs | 22 +++------------------- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/app.rs b/src/app.rs index 867f5f2..eaab3be 100644 --- a/src/app.rs +++ b/src/app.rs @@ -8,18 +8,10 @@ use std::collections::BTreeMap; use self::clap::{App, Arg, ArgGroup, AppSettings}; use super::{Slurp, RunOptions, compile, DEFAULT_SHELL, maybe_s}; -macro_rules! warn { - ($($arg:tt)*) => {{ - extern crate std; - use std::io::prelude::*; - let _ = writeln!(&mut std::io::stderr(), $($arg)*); - }}; -} - macro_rules! die { ($($arg:tt)*) => {{ extern crate std; - warn!($($arg)*); + eprintln!($($arg)*); process::exit(EXIT_FAILURE) }}; } @@ -235,7 +227,7 @@ pub fn app() { if matches.is_present("SUMMARY") { if justfile.count() == 0 { - warn!("Justfile contains no recipes."); + eprintln!("Justfile contains no recipes."); } else { println!("{}", justfile.recipes.keys().cloned().collect::>().join(" ")); } @@ -274,9 +266,9 @@ pub fn app() { process::exit(EXIT_SUCCESS); } None => { - warn!("Justfile does not contain recipe `{}`.", name); + eprintln!("Justfile does not contain recipe `{}`.", name); if let Some(suggestion) = justfile.suggest(name) { - warn!("Did you mean `{}`?", suggestion); + eprintln!("Did you mean `{}`?", suggestion); } process::exit(EXIT_FAILURE) } @@ -310,9 +302,9 @@ pub fn app() { if let Err(run_error) = justfile.run(&arguments, &options) { if !options.quiet { if color.stderr().active() { - warn!("{:#}", run_error); + eprintln!("{:#}", run_error); } else { - warn!("{}", run_error); + eprintln!("{}", run_error); } } diff --git a/src/lib.rs b/src/lib.rs index da585c9..4fd0eb2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,22 +51,6 @@ use std::collections::{BTreeMap as Map, BTreeSet as Set}; use std::fmt::Display; use std::ops::Range; -macro_rules! warn { - ($($arg:tt)*) => {{ - extern crate std; - use std::io::prelude::*; - let _ = writeln!(&mut std::io::stderr(), $($arg)*); - }}; -} - -macro_rules! die { - ($($arg:tt)*) => {{ - extern crate std; - warn!($($arg)*); - process::exit(EXIT_FAILURE) - }}; -} - const DEFAULT_SHELL: &'static str = "sh"; trait Slurp { @@ -290,7 +274,7 @@ impl<'a> Recipe<'a> { ) -> Result<(), RunError<'a>> { if options.verbose { let color = options.color.stderr().banner(); - warn!("{}===> Running recipe `{}`...{}", color.prefix(), self.name, color.suffix()); + eprintln!("{}===> Running recipe `{}`...{}", color.prefix(), self.name, color.suffix()); } let mut argument_map = Map::new(); @@ -333,7 +317,7 @@ impl<'a> Recipe<'a> { if options.dry_run || self.quiet { for line in &evaluated_lines { - warn!("{}", line); + eprintln!("{}", line); } } @@ -440,7 +424,7 @@ impl<'a> Recipe<'a> { } else { options.color }; - warn!("{}", color.stderr().paint(command)); + eprintln!("{}", color.stderr().paint(command)); } if options.dry_run {