Starting the Clap CLI parser

This commit is contained in:
2025-05-24 13:52:32 -05:00
parent 2067964a80
commit 408b0108a5
4 changed files with 37 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
clap = "4.0.32"
clap = { version = "4.0.7", features = ["derive"] }
reqwest = { version = "0.11.13", features = ["json"] }
serde = { version = "1.0.152", features = ["derive"] }
tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] }

24
src/cli.rs Normal file
View File

@@ -0,0 +1,24 @@
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>,
#[arg(short = 'n', long = "repo_name")]
repo_name: Option<String>,
#[command(subcommand)]
command: Option<Commands>
}
#[derive(Subcommand, Debug)]
enum Commands {
ListReleases{
#[arg(short, long)]
list: bool,
},
}

View File

@@ -1,5 +1,7 @@
use serde::Deserialize;
pub mod cli;
pub fn module_echo(){
println!("hello from lib.rs!");
}

View File

@@ -1,4 +1,9 @@
use gt_tools::ReleaseInfo;
use gt_tools::{
ReleaseInfo,
cli::Args
};
use clap::Parser;
use reqwest::Error;
use reqwest::header::{
@@ -8,6 +13,10 @@ use reqwest::header::{
#[tokio::main]
async fn main() -> Result<(), Error> {
let args = Args::parse();
println!("{:?}", args);
let request_url = format!(
"http:/localhost:3000/api/v1/repos/{owner}/{repo}/releases",
owner = "robert",