Starting the Clap CLI parser
This commit is contained in:
@@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "4.0.32"
|
clap = { version = "4.0.7", features = ["derive"] }
|
||||||
reqwest = { version = "0.11.13", features = ["json"] }
|
reqwest = { version = "0.11.13", features = ["json"] }
|
||||||
serde = { version = "1.0.152", features = ["derive"] }
|
serde = { version = "1.0.152", features = ["derive"] }
|
||||||
tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|||||||
24
src/cli.rs
Normal file
24
src/cli.rs
Normal 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,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
pub mod cli;
|
||||||
|
|
||||||
pub fn module_echo(){
|
pub fn module_echo(){
|
||||||
println!("hello from lib.rs!");
|
println!("hello from lib.rs!");
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@@ -1,4 +1,9 @@
|
|||||||
use gt_tools::ReleaseInfo;
|
use gt_tools::{
|
||||||
|
ReleaseInfo,
|
||||||
|
cli::Args
|
||||||
|
};
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
use reqwest::Error;
|
use reqwest::Error;
|
||||||
use reqwest::header::{
|
use reqwest::header::{
|
||||||
@@ -8,6 +13,10 @@ use reqwest::header::{
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Error> {
|
async fn main() -> Result<(), Error> {
|
||||||
|
let args = Args::parse();
|
||||||
|
|
||||||
|
println!("{:?}", args);
|
||||||
|
|
||||||
let request_url = format!(
|
let request_url = format!(
|
||||||
"http:/localhost:3000/api/v1/repos/{owner}/{repo}/releases",
|
"http:/localhost:3000/api/v1/repos/{owner}/{repo}/releases",
|
||||||
owner = "robert",
|
owner = "robert",
|
||||||
|
|||||||
Reference in New Issue
Block a user