From 44ed7210c4b4f36596113607bb17c915e9b404c5 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Mon, 22 Jul 2024 13:33:35 +0200 Subject: [PATCH] feat(solver): add verbosity flag --- Cargo.toml | 2 +- src/bin/solve/simple.rs | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 68d345b..aadc5a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ anyhow = "1.0.81" chrono = { version = "0.4.37" } clap = { version = "4.5.3", features = ["derive"], optional = true } colored = { version = "2.1.0", optional = false } -libpt = "0.6.0" +libpt = { version = "0.6.0", features = ["cli"] } num_cpus = "1.16.0" rand = "0.8.5" rayon = "1.10.0" diff --git a/src/bin/solve/simple.rs b/src/bin/solve/simple.rs index e235562..0219d70 100644 --- a/src/bin/solve/simple.rs +++ b/src/bin/solve/simple.rs @@ -2,8 +2,13 @@ // #![warn(missing_docs)] #![warn(missing_debug_implementations)] -use clap::Parser; +use clap::{Parser, Subcommand}; +use libpt::cli::{ + repl::{DefaultRepl, Repl}, + strum, +}; use libpt::log::*; +use strum::IntoEnumIterator; use wordle_analyzer::game::response::GuessResponse; @@ -25,8 +30,8 @@ struct Cli { #[arg(short, long, default_value_t = wordle_analyzer::DEFAULT_MAX_STEPS)] max_steps: usize, /// more verbose logs - #[arg(short, long)] - verbose: bool, + #[command(flatten)] + verbose: libpt::cli::args::VerbosityLevel, /// which solver to use #[arg(short, long, default_value_t = BuiltinSolverNames::default())] solver: BuiltinSolverNames, @@ -34,12 +39,13 @@ struct Cli { fn main() -> anyhow::Result<()> { let cli = Cli::parse(); - if cli.verbose { - Logger::builder().set_level(Level::DEBUG).build().unwrap(); - } else { - Logger::builder().set_level(Level::INFO).build().unwrap(); - } - debug!("dumping CLI: {:#?}", cli); + Logger::builder() + .set_level(cli.verbose.level()) + .build() + .unwrap(); + trace!("dumping CLI: {:#?}", cli); + + // let repl = libpt::cli::repl::DefaultRepl::::default(); let wl = BuiltinWList::default(); let builder = game::Game::builder(&wl)