added config speicifc printing macros

fuck_this_bullshit
Avril 3 years ago
parent 9f4a0faa68
commit ec35671398
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -54,6 +54,8 @@ pub struct Config
pub recursive: Recursion,
pub max_tasks: Option<NonZeroUsize>,
pub silent: bool,
#[cfg(feature="inspect")]
pub serialise_output: Option<Option<PathBuf>>, // Some(None) means dump to `stdout`
}
@ -94,6 +96,7 @@ impl Default for Config
paths: Vec::new(),
recursive: Default::default(),
max_tasks: None, //max_tasks_cpus(),
silent: false,
#[cfg(feature="inspect")]
serialise_output: None,
}
@ -145,3 +148,30 @@ impl fmt::Display for InvalidConfigError
}
}
}
/// Print an error line in accordance with `Config`'s output directives.
#[macro_export] macro_rules! cfg_eprintln {
($cfg:expr, $fmt:literal $($tt:tt)*) => {
{
if !$cfg.silent {
eprintln!($fmt $($tt)*);
}
}
}
}
/// Print a line in accordance with `Config`'s output directives.
#[macro_export] macro_rules! cfg_println {
($cfg:expr, $fmt:literal $($tt:tt)*) => {
{
let cfg = &$cfg;
if !cfg.silent {
if cfg.is_using_stdout() {
eprintln!($fmt $($tt)*);
} else {
println!($fmt $($tt)*);
}
}
}
}
}

@ -88,11 +88,7 @@ fn walk(state: State, root: PathBuf, root_ino: INode) -> BoxFuture<'static, Hash
async move {
{
let _guard = state.lock().enter().await;
if state.config().is_using_stdout() {
eprintln!(" -> {:?}", root);
} else {
println!(" -> {:?}", root);
}
cfg_println!(state.config(), " -> {:?}", root);
match fs::read_dir(&root).await
{
Ok(mut dir) => {

Loading…
Cancel
Save