hentaihavenrs/src/main.rs

52 lines
1.6 KiB
Rust
Raw Normal View History

2021-02-13 08:01:33 +00:00
mod commands;
mod structs;
mod utils;
2022-04-30 13:07:56 +00:00
use clap::{Arg, Command};
2021-02-13 08:01:33 +00:00
extern crate tokio;
fn main() {
2022-04-30 13:07:56 +00:00
let matches = Command::new("hentaihavenrs")
2021-02-13 08:01:33 +00:00
.about("hentaihaven.tv downloader in rust")
.version(env!("CARGO_PKG_VERSION"))
2022-04-30 13:07:56 +00:00
.subcommand_required(true)
2021-02-13 08:01:33 +00:00
.subcommand(
2022-04-30 13:07:56 +00:00
Command::new("search").arg(
Arg::new("query")
2021-02-13 08:01:33 +00:00
.takes_value(true)
2022-04-30 13:07:56 +00:00
.multiple_values(true)
.help("Search query"),
),
2021-02-13 08:01:33 +00:00
)
.subcommand(
2022-04-30 13:07:56 +00:00
Command::new("view").visible_aliases(&["info", "show"]).arg(
Arg::new("id")
2021-02-13 08:01:33 +00:00
.takes_value(true)
2022-04-30 13:07:56 +00:00
.multiple_values(true)
.required(true),
),
2021-02-13 08:01:33 +00:00
)
.subcommand(
2022-04-30 13:07:56 +00:00
Command::new("download")
.visible_alias("dl")
.arg(
Arg::new("print")
.long("print")
.short('p')
.help("Print the URL to download only"),
)
.arg(Arg::new("id").takes_value(true).required(true)),
2021-02-13 08:01:33 +00:00
)
.get_matches();
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
match matches.subcommand() {
2022-04-30 13:07:56 +00:00
Some(("search", sub_m)) => runtime.block_on(commands::search(sub_m)),
Some(("view", sub_m)) => runtime.block_on(commands::view(sub_m)),
Some(("download", sub_m)) => runtime.block_on(commands::download(sub_m)),
_ => unreachable!("subcommand_required do your job please"),
2021-02-13 08:01:33 +00:00
};
}