generated from PlexSheep/rs-base
fix!: less dependencies and simpler cli #6
This commit is contained in:
parent
f6c9c3c820
commit
fb145a7ff4
|
@ -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"
|
||||
|
|
21
src/main.rs
21
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<InfoLevel>,
|
||||
/// 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();
|
||||
|
|
Reference in New Issue