Skip to content

Commit 7a175c2

Browse files
authored
Merge branch 'master' into dictionary-curation-2026-06-15
2 parents 26a6928 + 66bf00b commit 7a175c2

6 files changed

Lines changed: 183 additions & 142 deletions

File tree

harper-cli/src/main.rs

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ enum Args {
128128
brief: bool,
129129
},
130130
/// Get all the forms of a word using the affixes.
131-
Forms { line: String },
131+
Forms {
132+
#[arg(num_args = 1..)]
133+
lines: Vec<String>,
134+
},
132135
/// Emit a decompressed, line-separated list of the words in Harper's dictionary.
133136
Words,
134137
/// Summarize a lint record
@@ -210,7 +213,7 @@ enum Args {
210213
/// As long as there's either an open or hyphenated spelling.
211214
Compounds,
212215
/// Emit a decompressed, line-separated list of the words in Harper's dictionary
213-
/// which occur in more than one lettercase variant.
216+
/// which occur in more than one lettercase variant.
214217
CaseVariants,
215218
/// Emit a list of each noun phrase contained within the input
216219
NominalPhrases {
@@ -436,65 +439,72 @@ fn main() -> anyhow::Result<()> {
436439

437440
Ok(())
438441
}
439-
Args::Forms { line } => {
440-
let (word, annot) = line_to_parts(&line);
442+
Args::Forms { lines } => {
443+
for (i, line) in lines.iter().enumerate() {
444+
if i > 0 {
445+
println!();
446+
}
441447

442-
let curated_word_list = include_str!("../../harper-core/dictionary.dict");
443-
let dict_lines = curated_word_list.split('\n');
448+
let (word, annot) = line_to_parts(line);
444449

445-
let mut entry_in_dict = None;
450+
let curated_word_list = include_str!("../../harper-core/dictionary.dict");
451+
let dict_lines = curated_word_list.split('\n');
446452

447-
// Check if the word is contained in the list.
448-
for dict_line in dict_lines {
449-
let (dict_word, dict_annot) = line_to_parts(dict_line);
453+
let mut entry_in_dict = None;
450454

451-
if dict_word == word {
452-
entry_in_dict = Some((dict_word, dict_annot));
453-
break;
454-
}
455-
}
455+
// Check if the word is contained in the list.
456+
for dict_line in dict_lines {
457+
let (dict_word, dict_annot) = line_to_parts(dict_line);
456458

457-
let summary = match &entry_in_dict {
458-
Some((dict_word, dict_annot)) => {
459-
let mut status_summary = if dict_annot.is_empty() {
460-
format!("'{dict_word}' is already in the dictionary but not annotated.")
461-
} else {
462-
format!(
463-
"'{dict_word}' is already in the dictionary with annotation `{dict_annot}`."
464-
)
465-
};
459+
if dict_word == word {
460+
entry_in_dict = Some((dict_word, dict_annot));
461+
break;
462+
}
463+
}
466464

467-
if !annot.is_empty() {
468-
if annot.as_str() != dict_annot.as_str() {
469-
status_summary
470-
.push_str("\n Your annotations differ from the dictionary.\n");
465+
let summary = match &entry_in_dict {
466+
Some((dict_word, dict_annot)) => {
467+
let mut status_summary = if dict_annot.is_empty() {
468+
format!("'{dict_word}' is already in the dictionary but not annotated.")
471469
} else {
472-
status_summary
473-
.push_str("\n Your annotations are the same as the dictionary.\n");
470+
format!(
471+
"'{dict_word}' is already in the dictionary with annotation `{dict_annot}`."
472+
)
473+
};
474+
475+
if !annot.is_empty() {
476+
if annot.as_str() != dict_annot.as_str() {
477+
status_summary
478+
.push_str("\n Your annotations differ from the dictionary.\n");
479+
} else {
480+
status_summary.push_str(
481+
"\n Your annotations are the same as the dictionary.\n",
482+
);
483+
}
474484
}
485+
486+
status_summary
475487
}
488+
None => format!("'{word}' is not in the dictionary yet."),
489+
};
476490

477-
status_summary
478-
}
479-
None => format!("'{word}' is not in the dictionary yet."),
480-
};
491+
println!("{summary}");
481492

482-
println!("{summary}");
483-
484-
if let Some((dict_word, dict_annot)) = &entry_in_dict {
485-
println!("Old, from the dictionary:");
486-
print_word_derivations(dict_word, dict_annot, &FstDictionary::curated());
487-
};
493+
if let Some((dict_word, dict_annot)) = &entry_in_dict {
494+
println!("Old, from the dictionary:");
495+
print_word_derivations(dict_word, dict_annot, &FstDictionary::curated());
496+
};
488497

489-
if !annot.is_empty() {
490-
let rune_words = format!("1\n{line}");
491-
let dict = MutableDictionary::from_rune_files(
492-
&rune_words,
493-
include_str!("../../harper-core/annotations.json"),
494-
)?;
498+
if !annot.is_empty() {
499+
let rune_words = format!("1\n{line}");
500+
let dict = MutableDictionary::from_rune_files(
501+
&rune_words,
502+
include_str!("../../harper-core/annotations.json"),
503+
)?;
495504

496-
println!("New, from you:");
497-
print_word_derivations(&word, &annot, &dict);
505+
println!("New, from you:");
506+
print_word_derivations(&word, &annot, &dict);
507+
}
498508
}
499509

500510
Ok(())

harper-core/default_config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,13 @@
13171317
"label": "Expand Coordinate"
13181318
}
13191319
},
1320+
{
1321+
"Bool": {
1322+
"name": "ExpandDirectory",
1323+
"state": true,
1324+
"label": "Expand Directory"
1325+
}
1326+
},
13201327
{
13211328
"Bool": {
13221329
"name": "ExpandNotification",

0 commit comments

Comments
 (0)