From 929175b3f910d6b1a965aae8195b724c0044a9c3 Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:11:55 +0900 Subject: [PATCH] :sparkles: Add support verbosity option to command line argument --- src/cli.rs | 2 ++ src/main.rs | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 3937fe7..9563e3b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -12,6 +12,8 @@ use clap::{Parser, Subcommand}; pub(crate) struct Cli { #[clap(subcommand)] pub(crate) subcommand: SubCommand, + #[command(flatten)] + pub(crate) verbose: clap_verbosity_flag::Verbosity, } #[derive(Subcommand)] diff --git a/src/main.rs b/src/main.rs index 9c2ac47..e4ca37d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,9 @@ mod file_manager; mod filesystem; fn main() -> io::Result<()> { + let args = cli::Cli::parse(); #[cfg(feature = "logging")] - simple_logger::init_with_level(log::Level::Trace).map_err(io::Error::other)?; - command::entry(cli::Cli::parse()) + simple_logger::init_with_level(args.verbose.log_level().unwrap_or(log::Level::Trace)) + .map_err(io::Error::other)?; + command::entry(args) }