From aceaaf7e69eec6481b37b5c51d3659a24aa860eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Gr=C3=BCnewald?= <10533763+dhalucario@users.noreply.github.com> Date: Sat, 2 Aug 2025 16:16:50 +0200 Subject: [PATCH] Add r621cli as a small test utility --- r621cli/Cargo.toml | 4 ++++ r621cli/src/main.rs | 27 ++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/r621cli/Cargo.toml b/r621cli/Cargo.toml index 122911d..e9d8750 100644 --- a/r621cli/Cargo.toml +++ b/r621cli/Cargo.toml @@ -4,4 +4,8 @@ version = "0.1.0" edition = "2024" [dependencies] +anyhow = "1.0.98" +async-compat = "0.2.4" clap = { version = "4.5.42", features = ["derive"] } +r621 = { path = "../r621" } +smol = "2.0.2" diff --git a/r621cli/src/main.rs b/r621cli/src/main.rs index a3edfb3..72907df 100644 --- a/r621cli/src/main.rs +++ b/r621cli/src/main.rs @@ -1,17 +1,26 @@ mod cli; + use cli::{Cli, Action, ESixType}; use clap::Parser; +use r621::prelude::*; +use async_compat::CompatExt; -fn main() { - let cli = Cli::parse(); - - match (&cli.esix_type, &cli.action) { - (ESixType::Post, Action::Search {query}) => { +fn main() -> anyhow::Result<()> { + smol::block_on(async { + let cli = Cli::parse(); + let mut esix = Client::new(Authentication::Unauthorized, "r621cli/1.0")?; + 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(()) + }) }