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.
67 lines
1.1 KiB
67 lines
1.1 KiB
#![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<config::Config, args::Error>
|
|
{
|
|
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<dyn std::error::Error>>
|
|
{
|
|
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<dyn std::error::Error>>
|
|
{
|
|
let conf = parse_args()?;
|
|
|
|
work::work(conf)
|
|
}
|