From b9d0f82ccb040333d11d0a4ff935c0ca4132506a Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Thu, 23 May 2024 14:51:56 +0200 Subject: [PATCH] fix: less dependencies and simpler cli #6 --- Cargo.toml | 4 +--- src/main.rs | 21 +++++++-------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b6189ba..48ebb7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,6 @@ repository = "https://git.cscherr.de/PlexSheep/hedu" keywords = ["hexdumper"] [dependencies] -libpt = { version = "0.5.1", features = ["log", "bintols"] } +libpt = { version = "0.5.1", features = ["bintols"], default-features = false } clap = { version = "4.4.4", features = ["derive", "help"] } -clap-num = { version = "1.0.2" } -clap-verbosity-flag = { version = "2.0.1" } anyhow = "1.0.79" diff --git a/src/main.rs b/src/main.rs index 0d9bb64..06bdb5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,6 @@ use std::{fs::File, io::IsTerminal, path::PathBuf}; use libpt::log::{error, trace, warn, Level, Logger}; use clap::Parser; -use clap_verbosity_flag::{InfoLevel, Verbosity}; mod dumper; use dumper::{DataSource, Hedu}; @@ -29,10 +28,9 @@ Author: {author-with-newline} )] /// Hexdumper written in Rust pub struct Cli { - // clap_verbosity_flag seems to make this a global option implicitly - /// set a verbosity, multiple allowed (f.e. -vvv) - #[command(flatten)] - pub verbose: Verbosity, + /// show more details + #[arg(short, long)] + pub verbose: bool, /// show additional logging meta data #[arg(long)] @@ -119,15 +117,10 @@ fn main() { fn cli_parse() -> Cli { let cli = Cli::parse(); - let ll: Level = match cli.verbose.log_level().unwrap().as_str() { - "TRACE" => Level::TRACE, - "DEBUG" => Level::DEBUG, - "INFO" => Level::INFO, - "WARN" => Level::WARN, - "ERROR" => Level::ERROR, - _ => { - unreachable!(); - } + let ll: Level = if cli.verbose { + Level::INFO + } else { + Level::DEBUG }; if cli.meta { let _ = Logger::builder().max_level(ll).build();