From 62d70225ab7c5fbbec7a8650c6836c2cfe9ae238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos=20P=2E=20Bezerra?= Date: Fri, 15 Mar 2024 18:37:20 -0300 Subject: [PATCH] remove `macros.rs` module --- src/list.rs | 6 ++-- src/macros.rs | 76 --------------------------------------------------- src/main.rs | 3 -- 3 files changed, 3 insertions(+), 82 deletions(-) delete mode 100644 src/macros.rs diff --git a/src/list.rs b/src/list.rs index 6b86149..c065925 100644 --- a/src/list.rs +++ b/src/list.rs @@ -85,7 +85,7 @@ mod tree { use linked_hash_map::LinkedHashMap; use super::FileInArchive; - use crate::{utils::EscapedPathDisplay, warning}; + use crate::utils::{logger::warning, EscapedPathDisplay}; /// Directory tree #[derive(Debug, Default)] @@ -119,10 +119,10 @@ mod tree { match &self.file { None => self.file = Some(file), Some(file) => { - warning!( + warning(format!( "multiple files with the same name in a single directory ({})", EscapedPathDisplay::new(&file.path), - ); + )); } } } diff --git a/src/macros.rs b/src/macros.rs deleted file mode 100644 index 10a3ba5..0000000 --- a/src/macros.rs +++ /dev/null @@ -1,76 +0,0 @@ -//! Macros used on ouch. - -use std::io; - -/// Macro that prints \[INFO\] messages, wraps [`eprintln`]. -/// -/// There are essentially two different versions of the `info!()` macro: -/// - `info!(accessible, ...)` should only be used for short, important -/// information which is expected to be useful for e.g. blind users whose -/// text-to-speech systems read out every output line, which is why we -/// should reduce nonessential output to a minimum when running in -/// ACCESSIBLE mode -/// - `info!(inaccessible, ...)` can be used more carelessly / for less -/// important information. A seeing user can easily skim through more lines -/// of output, so e.g. reporting every single processed file can be helpful, -/// while it would generate long and hard to navigate text for blind people -/// who have to have each line of output read to them aloud, without to -/// ability to skip some lines deemed not important like a seeing person would. -#[macro_export] -macro_rules! info { - // Accessible (short/important) info message. - // Show info message even in ACCESSIBLE mode - (accessible, $($arg:tt)*) => {{ - use ::std::io::{stderr, Write}; - - use $crate::{macros::stderr_check, utils::colors::{YELLOW, RESET}}; - - let mut stderr = stderr().lock(); - - if $crate::accessible::is_running_in_accessible_mode() { - stderr_check(write!(stderr, "{}Info:{} ", *YELLOW, *RESET)); - } else { - stderr_check(write!(stderr, "{}[INFO]{} ", *YELLOW, *RESET)); - } - - stderr_check(writeln!(stderr, $($arg)*)); - }}; - // Inccessible (long/no important) info message. - // Print info message if ACCESSIBLE is not turned on - (inaccessible, $($arg:tt)*) => {{ - use ::std::io::{stderr, Write}; - - use $crate::{macros::stderr_check, utils::colors::{YELLOW, RESET}}; - - let mut stderr = stderr().lock(); - - if !$crate::accessible::is_running_in_accessible_mode() { - stderr_check(write!(stderr, "{}[INFO]{} ", *YELLOW, *RESET)); - stderr_check(writeln!(stderr, $($arg)*)); - } - }}; -} - -/// Macro that prints WARNING messages, wraps [`eprintln`]. -#[macro_export] -macro_rules! warning { - ($($arg:tt)*) => {{ - use ::std::io::{stderr, Write}; - - use $crate::{macros::stderr_check, utils::colors::{ORANGE, RESET}}; - - let mut stderr = stderr().lock(); - - if $crate::accessible::is_running_in_accessible_mode() { - stderr_check(write!(stderr, "{}Warning:{} ", *ORANGE, *RESET)); - } else { - stderr_check(write!(stderr, "{}[WARNING]{} ", *ORANGE, *RESET)); - } - - stderr_check(writeln!(stderr, $($arg)*)); - }}; -} - -pub fn stderr_check(result: io::Result<()>) { - result.expect("failed printing to stderr"); -} diff --git a/src/main.rs b/src/main.rs index f126c95..10ead08 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,3 @@ -// Macros should be declared first -pub mod macros; - pub mod accessible; pub mod archive; pub mod check;