mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
remove macros.rs
module
This commit is contained in:
parent
615a7d3c49
commit
62d70225ab
@ -85,7 +85,7 @@ mod tree {
|
|||||||
use linked_hash_map::LinkedHashMap;
|
use linked_hash_map::LinkedHashMap;
|
||||||
|
|
||||||
use super::FileInArchive;
|
use super::FileInArchive;
|
||||||
use crate::{utils::EscapedPathDisplay, warning};
|
use crate::utils::{logger::warning, EscapedPathDisplay};
|
||||||
|
|
||||||
/// Directory tree
|
/// Directory tree
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
@ -119,10 +119,10 @@ mod tree {
|
|||||||
match &self.file {
|
match &self.file {
|
||||||
None => self.file = Some(file),
|
None => self.file = Some(file),
|
||||||
Some(file) => {
|
Some(file) => {
|
||||||
warning!(
|
warning(format!(
|
||||||
"multiple files with the same name in a single directory ({})",
|
"multiple files with the same name in a single directory ({})",
|
||||||
EscapedPathDisplay::new(&file.path),
|
EscapedPathDisplay::new(&file.path),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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");
|
|
||||||
}
|
|
@ -1,6 +1,3 @@
|
|||||||
// Macros should be declared first
|
|
||||||
pub mod macros;
|
|
||||||
|
|
||||||
pub mod accessible;
|
pub mod accessible;
|
||||||
pub mod archive;
|
pub mod archive;
|
||||||
pub mod check;
|
pub mod check;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user