You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2 KiB

#![cfg_attr(nightly, feature(int_error_matching))]
#![cfg_attr(nightly, feature(linked_list_remove))]
#![cfg_attr(nightly, feature(const_fn))]
#![cfg_attr(nightly, feature(never_type))]
#![allow(dead_code)]
use cfg_if::cfg_if;
mod defer;
mod ext;
pub use ext::JoinStrsExt as _;
#[cfg(feature="splash")]
mod splash;
mod arg;
mod error;
pub use error::{ErrorExt as _, ResultExt as _};
mod stage;
mod leanify;
mod dir;
mod fixed_stack;
mod process;
mod work;
#[cfg(feature="progress")] mod maybe_single;
#[cfg(feature="progress")] mod task_list;
#[cfg(feature="progress")] mod progress;
async fn work() -> Result<(), Box<dyn std::error::Error>>
{
let args = arg::parse_args().await.with_prefix("failed to parse args")?;
let leanify = leanify::find_binary().with_prefix("Couldn't find leanify binary")?;
work::work(&args.flags, leanify, args.files, args.max_children).await
}
#[tokio::main]
async fn main() {
prettify_expect(work().await.map_err(|e| e.to_string()), "exited with error");
}
#[inline] fn prettify_expect<T,E,S>(res: Result<T,E>, msg: S) -> T
where S: AsRef<str>,
E: std::fmt::Display
{
match res {
Ok(v) => v,
Err(e) => {
eprintln!("\n{}: {}", msg.as_ref(), e);
std::process::exit(1)
},
}
}