feat: start affluences cli for testing

This commit is contained in:
Jef Roosens 2023-05-13 13:08:03 +02:00
parent 8909ac57a8
commit 29f13d49b9
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
7 changed files with 269 additions and 14 deletions

12
affluences-cli/Cargo.toml Normal file
View file

@ -0,0 +1,12 @@
[package]
name = "affluences-cli"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
affluences-api = { path = "../affluences-api" }
clap = { version = "4.2.7", features = ["derive"] }
serde_json = "1.0.96"
tokio = { version = "1.28.1", features = ["full"] }

View file

@ -0,0 +1,30 @@
use affluences_api::AffluencesClient;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand)]
enum Commands {
/// does testing things
SearchSite { query: String },
}
#[tokio::main]
async fn main() {
let cli = Cli::parse();
let client = AffluencesClient::new();
match &cli.command {
Some(Commands::SearchSite { query }) => {
let res = client.search(query.to_string()).await.unwrap();
let s = serde_json::to_string_pretty(&res).unwrap();
println!("{}", s);
}
None => {}
}
}