From e84228ba01bd80623ba19013360a59a96ca8cee1 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sat, 11 Feb 2023 14:59:38 +1100 Subject: [PATCH] Read `log_level` from env `CARGO_BINSTALL_LOG_LEVEL` if arg not present (#790) * Enable feature "env" on dep clap in bin * Read log_level from env `CARGO_BINSTALL_LOG_LEVEL` if arg not present Signed-off-by: Jiahao XU --- crates/bin/Cargo.toml | 2 +- crates/bin/src/args.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/bin/Cargo.toml b/crates/bin/Cargo.toml index 97791471..3025aacf 100644 --- a/crates/bin/Cargo.toml +++ b/crates/bin/Cargo.toml @@ -24,7 +24,7 @@ pkg-fmt = "zip" [dependencies] binstalk = { path = "../binstalk", version = "0.8.0", default-features = false } binstalk-manifests = { path = "../binstalk-manifests", version = "0.3.0" } -clap = { version = "4.1.4", features = ["derive"] } +clap = { version = "4.1.4", features = ["derive", "env"] } crates_io_api = { version = "0.8.1", default-features = false } dirs = "4.0.0" fs-lock = { version = "0.1.0", path = "../fs-lock" } diff --git a/crates/bin/src/args.rs b/crates/bin/src/args.rs index 107c452c..8a3df325 100644 --- a/crates/bin/src/args.rs +++ b/crates/bin/src/args.rs @@ -226,7 +226,12 @@ pub struct Args { /// /// Set to `off` to disable logging completely, this will also /// disable output from `cargo-install`. - #[clap(help_heading = "Meta", long, value_name = "LEVEL")] + #[clap( + help_heading = "Meta", + long, + value_name = "LEVEL", + env = "CARGO_BINSTALL_LOG_LEVEL" + )] pub log_level: Option, /// Equivalent to setting `log_level` to `off`.