Files
gt-tool/src/main.rs
Robert Garrett f31f5b49da Move the URL and HTTP Client out of match block
I'm going to need these in several of the arms.
2025-05-24 14:53:16 -05:00

34 lines
854 B
Rust

use gt_tools::{ReleaseInfo, cli::Args};
use clap::Parser;
use reqwest::Error;
use reqwest::header::{ACCEPT, USER_AGENT};
#[tokio::main]
async fn main() -> Result<(), Error> {
let args = Args::parse();
let request_url = format!(
"http://localhost:3000/api/v1/repos/{owner}/{repo}/releases",
owner = "robert",
repo = "rcalc",
);
let client = reqwest::Client::new();
match args.command {
gt_tools::cli::Commands::ListReleases => {
let response = client
.get(request_url)
.header(USER_AGENT, "gt-tools-test-agent")
.header(ACCEPT, "application/json")
.send()
.await?;
let body_text: Vec<ReleaseInfo> = response.json().await?;
println!("{:?}", body_text);
}
}
Ok(())
}