generated from PlexSheep/rs-base
feat(wordlist): allow selection of wl in cli
cargo devel CI / cargo CI (push) Successful in 1m54s
Details
cargo devel CI / cargo CI (push) Successful in 1m54s
Details
This commit is contained in:
parent
e84c697a9e
commit
cbce9341e7
|
@ -41,6 +41,13 @@ struct Cli {
|
||||||
/// Note that the application as the whole will use at least one more thread.
|
/// Note that the application as the whole will use at least one more thread.
|
||||||
#[arg(short, long, default_value_t = num_cpus::get())]
|
#[arg(short, long, default_value_t = num_cpus::get())]
|
||||||
threads: usize,
|
threads: usize,
|
||||||
|
|
||||||
|
/// select a wordlist
|
||||||
|
///
|
||||||
|
/// 'ger' and 'eng' are special values bundled with this executable, if the value does not
|
||||||
|
/// match either of those, it will be assumed to be a file path.
|
||||||
|
#[arg(short, long, default_value_t = String::from("eng"))]
|
||||||
|
wordlist: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
|
@ -52,7 +59,11 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
trace!("dumping CLI: {:#?}", cli);
|
trace!("dumping CLI: {:#?}", cli);
|
||||||
|
|
||||||
let wl = BuiltinWList::default();
|
let wl = match cli.wordlist.as_str() {
|
||||||
|
"ger" => BuiltinWList::german(cli.length),
|
||||||
|
"eng" => BuiltinWList::english(cli.length),
|
||||||
|
_ => BuiltinWList::load(&cli.wordlist, cli.length)?,
|
||||||
|
};
|
||||||
let builder: GameBuilder<'_, BuiltinWList> = game::Game::builder(&wl)
|
let builder: GameBuilder<'_, BuiltinWList> = game::Game::builder(&wl)
|
||||||
.length(cli.length)
|
.length(cli.length)
|
||||||
.max_steps(cli.max_steps)
|
.max_steps(cli.max_steps)
|
||||||
|
|
|
@ -27,6 +27,12 @@ struct Cli {
|
||||||
/// more verbose logs
|
/// more verbose logs
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
|
/// select a wordlist
|
||||||
|
///
|
||||||
|
/// 'ger' and 'eng' are special values bundled with this executable, if the value does not
|
||||||
|
/// match either of those, it will be assumed to be a file path.
|
||||||
|
#[arg(short, long, default_value_t = String::from("eng"))]
|
||||||
|
wordlist: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
|
@ -38,7 +44,11 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
debug!("dumping CLI: {:#?}", cli);
|
debug!("dumping CLI: {:#?}", cli);
|
||||||
|
|
||||||
let wl = BuiltinWList::default();
|
let wl = match cli.wordlist.as_str() {
|
||||||
|
"ger" => BuiltinWList::german(cli.length),
|
||||||
|
"eng" => BuiltinWList::english(cli.length),
|
||||||
|
_ => BuiltinWList::load(&cli.wordlist, cli.length)?,
|
||||||
|
};
|
||||||
let builder = game::Game::builder(&wl)
|
let builder = game::Game::builder(&wl)
|
||||||
.length(cli.length)
|
.length(cli.length)
|
||||||
.max_steps(cli.max_steps)
|
.max_steps(cli.max_steps)
|
||||||
|
|
|
@ -50,6 +50,13 @@ struct Cli {
|
||||||
/// behavior.
|
/// behavior.
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
solution: Option<Word>,
|
solution: Option<Word>,
|
||||||
|
|
||||||
|
/// select a wordlist
|
||||||
|
///
|
||||||
|
/// 'ger' and 'eng' are special values bundled with this executable, if the value does not
|
||||||
|
/// match either of those, it will be assumed to be a file path.
|
||||||
|
#[arg(short, long, default_value_t = String::from("eng"))]
|
||||||
|
wordlist: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand, Debug, EnumIter, Clone)]
|
#[derive(Subcommand, Debug, EnumIter, Clone)]
|
||||||
|
@ -116,7 +123,11 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn help_guess_interactive(cli: Cli) -> anyhow::Result<()> {
|
fn help_guess_interactive(cli: Cli) -> anyhow::Result<()> {
|
||||||
let wl = BuiltinWList::default();
|
let wl = match cli.wordlist.as_str() {
|
||||||
|
"ger" => BuiltinWList::german(cli.length),
|
||||||
|
"eng" => BuiltinWList::english(cli.length),
|
||||||
|
_ => BuiltinWList::load(&cli.wordlist, cli.length)?,
|
||||||
|
};
|
||||||
let builder = game::GameBuilder::new(&wl, false)
|
let builder = game::GameBuilder::new(&wl, false)
|
||||||
.length(cli.length)
|
.length(cli.length)
|
||||||
.max_steps(cli.max_steps)
|
.max_steps(cli.max_steps)
|
||||||
|
@ -202,7 +213,12 @@ fn wlcommand_handler(_cli: &Cli, cmd: &WlCommand, wl: &impl WordList) -> anyhow:
|
||||||
}
|
}
|
||||||
|
|
||||||
fn play_native_non_interactive(cli: Cli) -> anyhow::Result<()> {
|
fn play_native_non_interactive(cli: Cli) -> anyhow::Result<()> {
|
||||||
let wl = BuiltinWList::default();
|
let wl = match cli.wordlist.as_str() {
|
||||||
|
"ger" => BuiltinWList::german(cli.length),
|
||||||
|
"eng" => BuiltinWList::english(cli.length),
|
||||||
|
_ => BuiltinWList::load(&cli.wordlist, cli.length)?,
|
||||||
|
};
|
||||||
|
debug!("wordlist: {wl}");
|
||||||
let mut builder = game::Game::builder(&wl)
|
let mut builder = game::Game::builder(&wl)
|
||||||
.length(cli.length)
|
.length(cli.length)
|
||||||
.max_steps(cli.max_steps)
|
.max_steps(cli.max_steps)
|
||||||
|
|
Loading…
Reference in New Issue