From e012aa80006a0de8135929243e1311958b791048 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 29 Jul 2025 08:13:18 +0200 Subject: Add weight to words MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows for the user to give more importance to some words than others, as that will be taken into account when running `practice`. Signed-off-by: Miquel Sabaté Solà --- crates/cli/src/words.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'crates/cli/src/words.rs') diff --git a/crates/cli/src/words.rs b/crates/cli/src/words.rs index 4743001..72748ae 100644 --- a/crates/cli/src/words.rs +++ b/crates/cli/src/words.rs @@ -260,6 +260,21 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result return Err("abort!".to_string()); }; + let Ok(raw_weight) = Text::new("Weight:") + .with_initial_value(word.weight.to_string().as_str()) + .prompt() + else { + return Err("abort!".to_string()); + }; + let Ok(weight) = raw_weight.parse::() else { + return Err(format!("bad value for inflection ID '{inflection}'")); + }; + if weight > 10 { + return Err(format!( + "weight has to be an integer between 0 and 10, but {weight} was given" + )); + } + let raw_flags = serde_json::to_string(&word.flags).unwrap(); let Ok(flags) = Editor::new("Flags:") @@ -316,6 +331,7 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result flags: serde_json::from_str(&trimmed_flags).unwrap(), succeeded: 0, steps: 0, + weight, }) } -- cgit v1.2.3