feat: Support --verbose flag

This commit is contained in:
Awiteb 2024-04-30 17:06:01 +03:00
parent 8cf18db314
commit e14fe76960
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F
2 changed files with 10 additions and 4 deletions

View file

@ -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<PathBuf>,
/// Show the logs in the stdout
#[arg(short, long)]
vaults_file: Option<PathBuf>,
pub verbose: bool,
// TODO: verbose flag
#[command(subcommand)]
command: Commands,
pub command: Commands,
}
impl Cli {

View file

@ -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)