From 5deb84668a4692df699814761a34f8bbbee80aec Mon Sep 17 00:00:00 2001 From: ozzy Date: Sun, 30 Aug 2026 15:52:10 -0500 Subject: [PATCH] feat(cli): allow filtering of parts of speech --- src/main.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.rs b/src/main.rs index 8fa6c79..5a73661 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,12 +2,28 @@ use clap::Parser; use colored::Colorize; use serde::Deserialize; +static POSSIBLE_PARTS_OF_SPEECH: &[&str] = &[ + "noun", + "verb", + "adjective", + "adverb", + "pronoun", + "preposition", + "conjunction", + "interjection", + "exclamation", + "determiner", + "article", +]; + #[derive(Parser, Debug)] #[command(version, about, long_about = None)] struct Args { word: String, #[arg(short, long, default_value = "en")] language: String, + #[arg(short, long, default_values = POSSIBLE_PARTS_OF_SPEECH)] + parts_of_speech: Vec, #[arg(short, long, action = clap::ArgAction::SetTrue)] examples: bool, } @@ -52,6 +68,9 @@ async fn main() { let result = result.unwrap(); for entry in result.entries { + if !args.parts_of_speech.contains(&entry.part_of_speech) { + continue; + } println!( "{} ({})", result.word.yellow().underline(),