@@ 306,7 306,7 @@ dependencies = [
[[package]]
name = "der_die_das"
-version = "0.2.0"
+version = "0.2.1"
dependencies = [
"clap",
"clap_complete_command",
@@ 48,29 48,46 @@ pub fn new_noun(
}
pub fn list_nouns(storage: Storage) -> Result<()> {
- let t = storage
- .all_nouns()?
+ let h = History {
+ nouns: storage.all_nouns()?,
+ attempts: storage.all_attempts()?,
+ };
+
+ h.grouped_confidence_map()
.iter()
- .fold(comfy_table::Table::new(), |mut table, w| {
- let id_cell = Cell::new(w.id);
- let article_cell = Cell::new(w.articles.iter().fold(String::new(), |s, a| {
- if s.is_empty() {
- a.to_string()
- } else {
- format!("{s}, {}", a.red().bold())
- }
- }));
- let word_cell = Cell::new(&w.word);
- let meaning_cell = Cell::new(&w.meaning);
- let mut r = Row::new();
- r.add_cell(id_cell)
- .add_cell(article_cell)
- .add_cell(word_cell)
- .add_cell(meaning_cell);
- table.add_row(r);
- table
+ .map(|(group, items)| {
+ let t = items
+ .iter()
+ .fold(comfy_table::Table::new(), |mut table, w| {
+ let id_cell = Cell::new(w.0.id);
+ let article_cell =
+ Cell::new(w.0.articles.iter().fold(String::new(), |s, a| {
+ if s.is_empty() {
+ a.to_string()
+ } else {
+ format!("{s}, {}", a.red().bold())
+ }
+ }));
+ let word_cell = Cell::new(&w.0.word);
+ let meaning_cell = Cell::new(&w.0.meaning);
+ let confidence_cell = Cell::new(w.1);
+ let mut r = Row::new();
+ r.add_cell(id_cell)
+ .add_cell(article_cell)
+ .add_cell(word_cell)
+ .add_cell(meaning_cell)
+ .add_cell(confidence_cell);
+ table
+ .add_row(r)
+ .load_preset(comfy_table::presets::UTF8_FULL);
+ table
+ });
+ (group, t)
+ })
+ .for_each(|(group, t)| {
+ println!("{}", group.bold().reversed());
+ println!("{t}");
});
- println!("{t}");
Ok(())
}