feat(solver): add verbosity flag
cargo devel CI / cargo CI (push) Successful in 1m50s Details

This commit is contained in:
Christoph J. Scherr 2024-07-22 13:33:35 +02:00
parent 5f32f8227f
commit 44ed7210c4
2 changed files with 16 additions and 10 deletions

View File

@ -27,7 +27,7 @@ anyhow = "1.0.81"
chrono = { version = "0.4.37" } chrono = { version = "0.4.37" }
clap = { version = "4.5.3", features = ["derive"], optional = true } clap = { version = "4.5.3", features = ["derive"], optional = true }
colored = { version = "2.1.0", optional = false } colored = { version = "2.1.0", optional = false }
libpt = "0.6.0" libpt = { version = "0.6.0", features = ["cli"] }
num_cpus = "1.16.0" num_cpus = "1.16.0"
rand = "0.8.5" rand = "0.8.5"
rayon = "1.10.0" rayon = "1.10.0"

View File

@ -2,8 +2,13 @@
// #![warn(missing_docs)] // #![warn(missing_docs)]
#![warn(missing_debug_implementations)] #![warn(missing_debug_implementations)]
use clap::Parser; use clap::{Parser, Subcommand};
use libpt::cli::{
repl::{DefaultRepl, Repl},
strum,
};
use libpt::log::*; use libpt::log::*;
use strum::IntoEnumIterator;
use wordle_analyzer::game::response::GuessResponse; use wordle_analyzer::game::response::GuessResponse;
@ -25,8 +30,8 @@ struct Cli {
#[arg(short, long, default_value_t = wordle_analyzer::DEFAULT_MAX_STEPS)] #[arg(short, long, default_value_t = wordle_analyzer::DEFAULT_MAX_STEPS)]
max_steps: usize, max_steps: usize,
/// more verbose logs /// more verbose logs
#[arg(short, long)] #[command(flatten)]
verbose: bool, verbose: libpt::cli::args::VerbosityLevel,
/// which solver to use /// which solver to use
#[arg(short, long, default_value_t = BuiltinSolverNames::default())] #[arg(short, long, default_value_t = BuiltinSolverNames::default())]
solver: BuiltinSolverNames, solver: BuiltinSolverNames,
@ -34,12 +39,13 @@ struct Cli {
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
let cli = Cli::parse(); let cli = Cli::parse();
if cli.verbose { Logger::builder()
Logger::builder().set_level(Level::DEBUG).build().unwrap(); .set_level(cli.verbose.level())
} else { .build()
Logger::builder().set_level(Level::INFO).build().unwrap(); .unwrap();
} trace!("dumping CLI: {:#?}", cli);
debug!("dumping CLI: {:#?}", cli);
// let repl = libpt::cli::repl::DefaultRepl::<ReplCommand>::default();
let wl = BuiltinWList::default(); let wl = BuiltinWList::default();
let builder = game::Game::builder(&wl) let builder = game::Game::builder(&wl)