about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-23 14:09:15 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-23 14:09:15 +0200
commit0929e662cbf5cde2f0558df785830a24118c930e (patch)
treec1f5b4c3ece1e0b61c2eee50c889349262305970
parentstyle(treewide): Format (diff)
downloadyt-0929e662cbf5cde2f0558df785830a24118c930e.tar.gz
yt-0929e662cbf5cde2f0558df785830a24118c930e.zip
fix(cli/verbosity): Simplify setting the default level
-rw-r--r--src/cli.rs2
-rw-r--r--src/main.rs21
2 files changed, 8 insertions, 15 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 1638e05..d3ec262 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -30,7 +30,7 @@ pub struct CliArgs {
     pub command: Option<Command>,
 
     /// Increase message verbosity
-    #[arg(long="verbose", short = 'v', action = ArgAction::Count, default_value_t = u8::MAX)]
+    #[arg(long="verbose", short = 'v', action = ArgAction::Count)]
     pub verbosity: u8,
 
     /// Set the path to the videos.db. This overrides the default and the config file.
diff --git a/src/main.rs b/src/main.rs
index 5e22dc7..94c0f71 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -46,14 +46,8 @@ pub mod watch;
 async fn main() -> Result<()> {
     let args = cli::CliArgs::parse();
 
-    let verbosity: u8 = if args.verbosity == u8::MAX {
-        // the user did not specify a verbosity
-        2 // log::Level::Warn
-    } else {
-        assert!(args.verbosity > 0);
-
-        args.verbosity + 2 // log::Level::Warn
-    };
+    // The default verbosity is 1 (Warn)
+    let verbosity: u8 = args.verbosity + 1;
 
     stderrlog::new()
         .module(module_path!())
@@ -68,12 +62,11 @@ async fn main() -> Result<()> {
 
     info!("Using verbosity level: '{} ({})'", verbosity, {
         match verbosity {
-            0 => "Off",
-            1 => "Error",
-            2 => "Warn",
-            3 => "Info",
-            4 => "Debug",
-            5.. => "Trace",
+            0 => "Error",
+            1 => "Warn",
+            2 => "Info",
+            3 => "Debug",
+            4.. => "Trace",
         }
     });