Starting the Clap CLI parser
This commit is contained in:
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;
|
||||
|
||||
pub mod cli;
|
||||
|
||||
pub fn module_echo(){
|
||||
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::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",
|
||||
|
||||
Reference in New Issue
Block a user