From dfc30b6d3a46c90906251ced63ef3d82f59f8762 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 29 Mar 2026 21:13:31 -0400 Subject: [PATCH] Add FABRO_* environment variables for global CLI args Enable clap's `env` feature and wire each global flag to a corresponding environment variable (FABRO_DEBUG, FABRO_QUIET, FABRO_VERBOSE, FABRO_NO_UPGRADE_CHECK, FABRO_STORAGE_DIR, FABRO_SERVER_URL). Boolean flags use BoolishValueParser so they accept 1/true/yes/on and their inverses. Co-Authored-By: Claude Opus 4.6 (1M context) --- Cargo.toml | 2 +- lib/crates/fabro-cli/src/args.rs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dfb622b0d..54b15a95b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ async-trait = "0.1" base64 = "0.22" bytes = "1" tokio-util = "0.7" -clap = { version = "4", features = ["derive"] } +clap = { version = "4", features = ["derive", "env"] } jsonschema = { version = "0.42", default-features = false } chrono = { version = "0.4", features = ["clock"] } bollard = "0.18" diff --git a/lib/crates/fabro-cli/src/args.rs b/lib/crates/fabro-cli/src/args.rs index 9d9379b88..b64d9995b 100644 --- a/lib/crates/fabro-cli/src/args.rs +++ b/lib/crates/fabro-cli/src/args.rs @@ -18,28 +18,33 @@ pub(crate) const LONG_VERSION: &str = concat!( #[derive(Args)] pub(crate) struct GlobalArgs { /// Enable DEBUG-level logging (default is INFO) - #[arg(long, global = true)] + #[arg(long, global = true, env = "FABRO_DEBUG", value_parser = clap::builder::BoolishValueParser::new())] pub debug: bool, /// Disable automatic upgrade check - #[arg(long, global = true)] + #[arg(long, global = true, env = "FABRO_NO_UPGRADE_CHECK", value_parser = clap::builder::BoolishValueParser::new())] pub no_upgrade_check: bool, /// Suppress non-essential output - #[arg(long, global = true, conflicts_with = "verbose")] + #[arg(long, global = true, env = "FABRO_QUIET", value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "verbose")] pub quiet: bool, /// Enable verbose output - #[arg(long, global = true, conflicts_with = "quiet")] + #[arg(long, global = true, env = "FABRO_VERBOSE", value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "quiet")] pub verbose: bool, /// Storage directory (default: ~/.fabro) - #[arg(long, global = true)] + #[arg(long, global = true, env = "FABRO_STORAGE_DIR")] pub storage_dir: Option, #[cfg(feature = "server")] /// Server URL (overrides server.base_url from cli.toml) - #[arg(long, global = true, conflicts_with = "storage_dir")] + #[arg( + long, + global = true, + env = "FABRO_SERVER_URL", + conflicts_with = "storage_dir" + )] pub server_url: Option, }