Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: `get-correct-capitalization-of` command for `harper-cli` (#4263)
Andrew Dunbar558514448d18
diff --git a/harper-cli/src/main.rs b/harper-cli/src/main.rsindex 67ef36db5..519b1f09d 100644--- a/harper-cli/src/main.rs+++ b/harper-cli/src/main.rs@@ -232,6 +232,11 @@ enum Args {#[arg(value_hint = ValueHint::FilePath)]input: PathBuf,},+ /// Get the correct capitalization of a word.+ GetCorrectCapitalizationOf {+ /// The word to get the correct capitalization for.+ word: String,+ },/// Generate shell completions.#[command(hide = true)]Completion {@@ -1010,6 +1015,19 @@ fn main() -> anyhow::Result<()> {process::exit(1);}}+ Args::GetCorrectCapitalizationOf { word } => {+ let word_chars: Vec<char> = word.chars().collect();+ if let Some(correct_capitalization) =+ curated_dictionary.get_correct_capitalization_of(&word_chars)+ {+ let correct_word: String = correct_capitalization.iter().collect();+ println!("{correct_word}");+ } else {+ eprintln!("No correct capitalization found for '{word}'");+ process::exit(1);+ }+ Ok(())+ }Args::Completion { shell } => {generate(shell,