Add r621cli as a small test utility
This commit is contained in:
parent
5d1ac75f10
commit
aceaaf7e69
2 changed files with 22 additions and 9 deletions
|
@ -4,4 +4,8 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = "1.0.98"
|
||||||
|
async-compat = "0.2.4"
|
||||||
clap = { version = "4.5.42", features = ["derive"] }
|
clap = { version = "4.5.42", features = ["derive"] }
|
||||||
|
r621 = { path = "../r621" }
|
||||||
|
smol = "2.0.2"
|
||||||
|
|
|
@ -1,17 +1,26 @@
|
||||||
mod cli;
|
mod cli;
|
||||||
|
|
||||||
|
|
||||||
use cli::{Cli, Action, ESixType};
|
use cli::{Cli, Action, ESixType};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use r621::prelude::*;
|
||||||
|
use async_compat::CompatExt;
|
||||||
|
|
||||||
fn main() {
|
fn main() -> anyhow::Result<()> {
|
||||||
let cli = Cli::parse();
|
smol::block_on(async {
|
||||||
|
let cli = Cli::parse();
|
||||||
match (&cli.esix_type, &cli.action) {
|
let mut esix = Client::new(Authentication::Unauthorized, "r621cli/1.0")?;
|
||||||
(ESixType::Post, Action::Search {query}) => {
|
|
||||||
|
|
||||||
|
match (&cli.esix_type, &cli.action) {
|
||||||
|
(ESixType::Post, Action::Search {query}) => {
|
||||||
|
let posts = esix.list_posts(None, Some(query.to_owned()), None).compat().await?;
|
||||||
|
println!("{posts:?}");
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
todo!("{:?} not implemented for {:?}", &cli.action, &cli.esix_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
todo!("{:?} not implemented for {:?}", &cli.action, &cli.esix_type);
|
Ok(())
|
||||||
}
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue