feat: start affluences cli for testing
This commit is contained in:
parent
8909ac57a8
commit
29f13d49b9
7 changed files with 269 additions and 14 deletions
12
affluences-cli/Cargo.toml
Normal file
12
affluences-cli/Cargo.toml
Normal 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"] }
|
||||
30
affluences-cli/src/main.rs
Normal file
30
affluences-cli/src/main.rs
Normal 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 => {}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue