#![cfg_attr(nightly, feature(linked_list_remove))] #![cfg_attr(nightly, feature(test))] #![allow(dead_code)] #[cfg(all(nightly, test))] extern crate test; use termprogress::{ ProgressBar, }; #[macro_use] mod ext; use ext::*; mod config; mod args; mod url; mod error; mod tempfile; mod loli; mod tags; mod search; #[cfg(feature="async")] mod work_async; #[cfg(not(feature="async"))] mod work; //mod list; pub fn parse_args() -> Result { match args::parse_args()? { args::Mode::Normal(conf) => Ok(conf), args::Mode::Help => args::usage(), } } #[cfg(feature="async")] #[cfg_attr(feature="async", tokio::main)] async fn main() -> Result<(), Box> { let conf = match parse_args() { Ok(v) => v, Err(e) => { eprintln!("Failed to parse args: {}", e); std::process::exit(1) }, }; if let Err(e) = work_async::work(conf).await { eprintln!("Worker error: {}", e); std::process::exit(1) } Ok(()) } #[cfg(not(feature="async"))] fn main() -> Result<(), Box> { let conf = parse_args()?; work::work(conf) }