feat(cli): allow filtering of parts of speech
This commit is contained in:
+19
@@ -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<String>,
|
||||
#[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(),
|
||||
|
||||
Reference in New Issue
Block a user