46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
use affluences_api::AffluencesClient;
|
|
use chrono::NaiveDate;
|
|
use clap::{Parser, Subcommand};
|
|
use uuid::{uuid, Uuid};
|
|
|
|
const STERRE_BIB_ID: Uuid = uuid!("4737e57a-ee05-4f7b-901a-7bb541eeb297");
|
|
|
|
#[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,
|
|
},
|
|
Available,
|
|
}
|
|
|
|
#[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);
|
|
}
|
|
Some(Commands::Available) => {
|
|
let res = client
|
|
.available(STERRE_BIB_ID, chrono::Utc::now().naive_utc().date(), 1)
|
|
.await
|
|
.unwrap();
|
|
let s = serde_json::to_string_pretty(&res).unwrap();
|
|
println!("{}", s);
|
|
}
|
|
None => {}
|
|
}
|
|
}
|