v0.2.0 #7

Merged
PlexSheep merged 15 commits from devel into master 2024-05-24 09:31:17 +02:00
2 changed files with 8 additions and 17 deletions
Showing only changes of commit fb145a7ff4 - Show all commits

View File

@ -12,8 +12,6 @@ repository = "https://git.cscherr.de/PlexSheep/hedu"
keywords = ["hexdumper"] keywords = ["hexdumper"]
[dependencies] [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 = { version = "4.4.4", features = ["derive", "help"] }
clap-num = { version = "1.0.2" }
clap-verbosity-flag = { version = "2.0.1" }
anyhow = "1.0.79" anyhow = "1.0.79"

View File

@ -8,7 +8,6 @@ use std::{fs::File, io::IsTerminal, path::PathBuf};
use libpt::log::{error, trace, warn, Level, Logger}; use libpt::log::{error, trace, warn, Level, Logger};
use clap::Parser; use clap::Parser;
use clap_verbosity_flag::{InfoLevel, Verbosity};
mod dumper; mod dumper;
use dumper::{DataSource, Hedu}; use dumper::{DataSource, Hedu};
@ -29,10 +28,9 @@ Author: {author-with-newline}
)] )]
/// Hexdumper written in Rust /// Hexdumper written in Rust
pub struct Cli { pub struct Cli {
// clap_verbosity_flag seems to make this a global option implicitly /// show more details
/// set a verbosity, multiple allowed (f.e. -vvv) #[arg(short, long)]
#[command(flatten)] pub verbose: bool,
pub verbose: Verbosity<InfoLevel>,
/// show additional logging meta data /// show additional logging meta data
#[arg(long)] #[arg(long)]
@ -119,15 +117,10 @@ fn main() {
fn cli_parse() -> Cli { fn cli_parse() -> Cli {
let cli = Cli::parse(); let cli = Cli::parse();
let ll: Level = match cli.verbose.log_level().unwrap().as_str() { let ll: Level = if cli.verbose {
"TRACE" => Level::TRACE, Level::INFO
"DEBUG" => Level::DEBUG, } else {
"INFO" => Level::INFO, Level::DEBUG
"WARN" => Level::WARN,
"ERROR" => Level::ERROR,
_ => {
unreachable!();
}
}; };
if cli.meta { if cli.meta {
let _ = Logger::builder().max_level(ll).build(); let _ = Logger::builder().max_level(ll).build();