#[macro_export]
macro_rules! out {
($($arg:tt)*) => {
let s = format!($($arg)*);
if $crate::cli::SHOULD_COPY.load(std::sync::atomic::Ordering::Relaxed) == 1 {
let mut clipboard = arboard::Clipboard::new().unwrap();
clipboard.set_text(&s).unwrap();
}
let output_file = $crate::cli::OUTPUT_PATH.lock().map_err(|_| anyhow!("Could not acquire lock to output file"))?;
if output_file.is_some() {
let path = output_file.as_ref().ok_or(anyhow!("No output found. Impossible"))?;
let path = std::path::Path::new(path);
let prefix = path.parent();
if let Some(prefix) = prefix {
std::fs::create_dir_all(prefix).map_err(|e| anyhow!("Unable to create parent directories for the file {}", e.to_string()))?;
}
std::fs::write(path, s.clone()).map_err(|e| anyhow!("Unable to create file: {}", e.to_string()))?;
}
log::info!("{}", s)
}
}