This repository has been archived on 2026-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
worldulu/src/cli.rs

87 lines
2.2 KiB
Rust

use std::fmt::Display;
use clap::{Parser, Subcommand, ValueEnum};
use crate::word_representation::Penalty;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub(crate) struct Args {
#[command(subcommand)]
pub(crate) command: Commands,
#[arg(long, short, value_enum, default_value_t=Wordtypes::Full)]
pub(crate) wordlist: Wordtypes,
/// Duplicate letters are set to this value
#[arg(short, long)]
pub(crate) set: isize,
/// Duplicate letters instead decrease the value by this amount
#[arg(short, long)]
pub(crate) sub: isize,
}
#[derive(Subcommand, Debug)]
pub(crate) enum Commands {
/// Tools to solve the wordle
Solve {
/// Contains these letters
#[arg(short, long)]
r#in: Option<String>,
/// Has these position, as a regex, use ^start, end$ and wor.d extensively
#[arg(short, long)]
pos: Option<String>,
/// Doesnt contains these letters
#[arg(short, long)]
out: Option<String>,
},
/// Tools to calculate best words for a wordle
List {
/// Number of guesses targetted
#[arg(short, long)]
number: Option<usize>,
/// How many branches to try, warning exponential solving time
#[arg(short, long, default_value_t = 5)]
depth: usize,
/// Solving algorithm
#[arg(short, long, value_enum, default_value_t = AlgoType::Best)]
algo: AlgoType,
},
}
/// The word list to use
#[derive(ValueEnum, Debug, Clone)]
pub(crate) enum Wordtypes {
/// A simplified list of words, more likely to appear in the wordle
Simple,
/// The full list of words legal in wordle
Full,
// /// Mixed word list, picks a simpler list for weights and full for coverage
// Mixed,
}
/// The word list to use
#[derive(ValueEnum, Debug, Clone)]
pub(crate) enum AlgoType {
/// Best candidate algorithm
Best,
/// Full candidate list
Full,
}
impl Display for AlgoType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AlgoType::Best => f.write_str("Best"),
AlgoType::Full => f.write_str("Full"),
}
}
}