From 5999661dbf985b194292cc0741aa41fbf68fa60f Mon Sep 17 00:00:00 2001 From: Duncan McGreggor Date: Thu, 21 Dec 2023 00:07:30 -0600 Subject: [PATCH] Added history counts to dupe output. --- rucksack/src/command/handlers/list.rs | 1 + rucksack/src/output/column.rs | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/rucksack/src/command/handlers/list.rs b/rucksack/src/command/handlers/list.rs index 6b6206b..3c47882 100644 --- a/rucksack/src/command/handlers/list.rs +++ b/rucksack/src/command/handlers/list.rs @@ -401,6 +401,7 @@ fn extract_results( result.add(Column::Category, md.category.clone()); result.add(Column::Count, md.access_count.to_string()); result.add(Column::Status, md.status().to_string()); + result.add(Column::HistoryCount, format!("{:}", record.history().len())); match opts.decrypted { true => { let pwd = if opts.reveal { diff --git a/rucksack/src/output/column.rs b/rucksack/src/output/column.rs index 9b2ddbc..6150f92 100644 --- a/rucksack/src/output/column.rs +++ b/rucksack/src/output/column.rs @@ -12,6 +12,7 @@ pub enum Column { Created, DupeInfo, Hash, + HistoryCount, Id, Imported, Key, @@ -39,6 +40,7 @@ impl Column { match self { Column::Count => "Access Count".to_string(), Column::DupeInfo => "Duplicate Info".to_string(), + Column::HistoryCount => "History Count".to_string(), Column::Kind => "Type".to_string(), Column::LastUpdated => "Last Updated".to_string(), Column::Score => "Score / Strength".to_string(), @@ -138,20 +140,20 @@ impl Columns for ColsGroupByName { } } +#[derive(Eq, PartialEq, PartialOrd)] pub struct ColsGroupByHash; impl Columns for ColsGroupByHash { fn pre(&self, _opts: &Opts) -> Vec { - vec![ - Column::Name, - Column::Kind, - Column::Category, - Column::DupeInfo, - ] + vec![Column::Kind, Column::Category, Column::DupeInfo] } fn post(&self, _opts: &Opts, mut cols: Vec) -> Vec { - cols.append(&mut vec![Column::Count, Column::LastUpdated, Column::Url]); + cols.append(&mut vec![ + Column::Count, + Column::LastUpdated, + Column::HistoryCount, + ]); cols } }