use clap::{ArgEnum, Parser};
use crate::wordlists::BuiltInWordlist;
const CLI_HELP: &str = "A trusty terminal typing tester.
Keyboard shortcuts:
ctrl-c: quit
ctrl-r: restart test with a new set of words
ctrc-w: delete last word
";
#[derive(Parser)]
#[clap(author, version, about = CLI_HELP)]
pub struct ToipeConfig {
#[clap(arg_enum, short, long, default_value_t = BuiltInWordlist::Top250)]
pub wordlist: BuiltInWordlist,
#[clap(short = 'f', long = "file", conflicts_with = "wordlist")]
pub wordlist_file: Option<String>,
#[clap(short, long, default_value_t = 30)]
pub num_words: usize,
#[clap(short, long)]
pub punctuation: bool,
}
impl ToipeConfig {
pub fn text_name(&self) -> String {
if let Some(wordlist_file) = &self.wordlist_file {
format!("custom file `{}`", wordlist_file)
} else {
if let Some(possible_value) = self.wordlist.to_possible_value() {
possible_value.get_name()
} else {
"unknown"
}
.to_string()
}
}
}