summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/src/main.rs6
-rw-r--r--cli/src/store.rs6
2 files changed, 7 insertions, 5 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index 55279b1..48bbb1d 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -71,7 +71,7 @@ struct Mn {
fn main() {
let mut store = Store::open(PathBuf::from("store")).unwrap();
- let search = Search::new(store.transactions().iter().collect());
+ let search = Search::new(store.transactions());
let search = search.subtract(Constraint::Category("a".to_string()));
let args = Mn::from_args();
@@ -108,7 +108,9 @@ fn main() {
println!("{}", store.categories().join("\n"));
}
Command::Show => {
- println!("{}", Table::new(store.transactions()).with(Style::psql()));
+ let mut transactions = store.transactions();
+ transactions.sort_by(|t1, t2| t1.date.cmp(&t2.date));
+ println!("{}", Table::new(transactions).with(Style::psql()));
}
}
}
diff --git a/cli/src/store.rs b/cli/src/store.rs
index 4e0e36b..6d20022 100644
--- a/cli/src/store.rs
+++ b/cli/src/store.rs
@@ -49,13 +49,13 @@ impl Store {
Ok(())
}
- pub fn transactions(&self) -> &[Transaction] {
- &self.transactions
+ pub fn transactions(&self) -> Vec<&Transaction> {
+ self.transactions.iter().collect()
}
pub fn categories(&self) -> Vec<Category> {
let mut categories: Vec<_> = self
- .transactions()
+ .transactions
.iter()
.map(|t| t.category.clone())
.collect();