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.
49 lines
833 B
49 lines
833 B
4 years ago
|
#![allow(dead_code)]
|
||
|
|
||
|
use termprogress::{
|
||
|
progress,
|
||
|
ProgressBar,
|
||
|
};
|
||
|
|
||
|
mod config;
|
||
|
mod args;
|
||
|
mod url;
|
||
|
mod error;
|
||
|
mod loli;
|
||
|
|
||
|
#[cfg(feature="async")]
|
||
|
mod work_async;
|
||
|
#[cfg(not(feature="async"))]
|
||
|
mod work;
|
||
|
|
||
|
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) => {
|
||
|
println!("Failed to parse args: {}", e);
|
||
|
std::process::exit(1)
|
||
|
},
|
||
|
};
|
||
|
|
||
|
work_async::work(conf).await
|
||
|
}
|
||
|
|
||
|
#[cfg(not(feature="async"))]
|
||
|
fn main() -> Result<(), Box<dyn std::error::Error>>
|
||
|
{
|
||
|
let conf = parse_args()?;
|
||
|
|
||
|
work::work(conf)
|
||
|
}
|