From 1210b168eee885f196bdebbe5e9a205b77748f9a Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Sat, 24 May 2025 19:00:35 -0500 Subject: [PATCH] Demo: missing CLI args can be filled via env vars --- Cargo.toml | 2 +- src/cli.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c73893a..4ecc1db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] -clap = { version = "4.0.7", features = ["derive"] } +clap = { version = "4.0.7", features = ["derive", "env"] } reqwest = { version = "0.11.13", features = ["json"] } serde = { version = "1.0.152", features = ["derive"] } tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] } diff --git a/src/cli.rs b/src/cli.rs index f49279f..a604f2a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -3,10 +3,10 @@ use clap::{Parser, Subcommand}; #[derive(Debug, Parser)] #[command(version, about, long_about = None)] pub struct Args { - #[arg(short = 'o', long = "owner")] - pub repo_owner: Option, - #[arg(short = 'n', long = "repo_name")] - pub repo_name: Option, + #[arg(short = 'o', long = "owner", env = "GTTOOL_OWNER")] + pub owner: String, + #[arg(short = 'r', long = "repo")] + pub repo: Option, #[command(subcommand)] pub command: Commands,