From e14fe76960d74cc8a6b4536de54e3c58732002f8 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Tue, 30 Apr 2024 17:06:01 +0300 Subject: [PATCH] feat: Support `--verbose` flag --- src/cli/mod.rs | 8 +++++--- src/main.rs | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 571ee34..a31ea04 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -58,12 +58,14 @@ impl_commands!(Commands, Add Remove List Clean Edit Gen Export Import); #[command(author, version, about, long_about = None)] pub struct Cli { /// The vaults json file + #[arg(short = 'f', long)] + pub vaults_file: Option, + /// Show the logs in the stdout #[arg(short, long)] - vaults_file: Option, + pub verbose: bool, - // TODO: verbose flag #[command(subcommand)] - command: Commands, + pub command: Commands, } impl Cli { diff --git a/src/main.rs b/src/main.rs index e7ee365..2d4a51d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,10 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const LAST_VERSION_CHECK_FILE: &str = ".last_version_check"; fn main() -> ExitCode { + let lprs_cli = cli::Cli::parse(); + if lprs_cli.verbose { + std::env::set_var("RUST_LOG", "lprs"); + } pretty_env_logger::init(); #[cfg(feature = "update-notify")] @@ -64,7 +68,7 @@ fn main() -> ExitCode { } } - if let Err(err) = cli::Cli::parse().run() { + if let Err(err) = lprs_cli.run() { if !matches!( err, LprsError::Inquire(InquireError::OperationCanceled)