diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-29 08:13:18 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-29 08:13:18 +0200 |
| commit | e012aa80006a0de8135929243e1311958b791048 (patch) | |
| tree | 8bd6878cc47d75633c150fa6f413577fc670d0f9 /crates/cli/src | |
| parent | 87a7b528482a1850731001ee8ccaccfd75c64824 (diff) | |
| download | mihi-e012aa80006a0de8135929243e1311958b791048.tar.gz mihi-e012aa80006a0de8135929243e1311958b791048.zip | |
Add weight to words
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à <mikisabate@gmail.com>
Diffstat (limited to 'crates/cli/src')
| -rw-r--r-- | crates/cli/src/words.rs | 16 |
1 files changed, 16 insertions, 0 deletions
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<Word, String> 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::<usize>() 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<Word, String> flags: serde_json::from_str(&trimmed_flags).unwrap(), succeeded: 0, steps: 0, + weight, }) } |
