Wire in the ListReleases primary command
Hey, look at that. I can do the thing what with the stuff and such.
This commit is contained in:
13
src/cli.rs
13
src/cli.rs
@@ -1,22 +1,19 @@
|
||||
use clap::{
|
||||
Parser,
|
||||
Subcommand
|
||||
};
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
#[arg(short = 'o', long = "owner")]
|
||||
repo_owner: Option<String>,
|
||||
pub repo_owner: Option<String>,
|
||||
#[arg(short = 'n', long = "repo_name")]
|
||||
repo_name: Option<String>,
|
||||
pub repo_name: Option<String>,
|
||||
|
||||
#[command(subcommand)]
|
||||
command: Option<Commands>
|
||||
pub command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
enum Commands {
|
||||
pub enum Commands {
|
||||
ListReleases {
|
||||
#[arg(short, long)]
|
||||
list: bool,
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct ReleaseInfo {
|
||||
prerelease: bool,
|
||||
created_at: String,
|
||||
published_at: String,
|
||||
author: Author
|
||||
author: Author,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
@@ -33,5 +33,5 @@ pub struct Author {
|
||||
login_name: String,
|
||||
source_id: usize,
|
||||
full_name: String,
|
||||
email: String
|
||||
email: String,
|
||||
}
|
||||
|
||||
17
src/main.rs
17
src/main.rs
@@ -1,22 +1,16 @@
|
||||
use gt_tools::{
|
||||
ReleaseInfo,
|
||||
cli::Args
|
||||
};
|
||||
use gt_tools::{ReleaseInfo, cli::Args};
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
use reqwest::Error;
|
||||
use reqwest::header::{
|
||||
USER_AGENT,
|
||||
ACCEPT
|
||||
};
|
||||
use reqwest::header::{ACCEPT, USER_AGENT};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Error> {
|
||||
let args = Args::parse();
|
||||
|
||||
println!("{:?}", args);
|
||||
|
||||
match args.command {
|
||||
gt_tools::cli::Commands::ListReleases { list } => {
|
||||
let request_url = format!(
|
||||
"http:/localhost:3000/api/v1/repos/{owner}/{repo}/releases",
|
||||
owner = "robert",
|
||||
@@ -32,5 +26,8 @@ async fn main() -> Result<(), Error> {
|
||||
let body_text: Vec<ReleaseInfo> = response.json().await?;
|
||||
|
||||
println!("{:?}", body_text);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user