diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-07-29 15:10:48 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-07-29 15:10:48 +0200 |
| commit | cf79a3180282f08a6165f4b88f52b78a14b9c688 (patch) | |
| tree | 4aa3419ff3459034575d5f5566ef98524da8523e /cli/src/main.rs | |
| parent | 174cd70001b8c01fc65c373e7dbd3ea6e0a6721c (diff) | |
| download | money-cf79a3180282f08a6165f4b88f52b78a14b9c688.tar.gz | |
initial searching
Diffstat (limited to 'cli/src/main.rs')
| -rw-r--r-- | cli/src/main.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs index 5fd52c7..071e251 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -4,9 +4,14 @@ use std::path::PathBuf; use std::str::FromStr; use structopt::StructOpt; +mod search; mod store; mod transaction; +use search::{Constraint, Search}; +use store::Store; +use transaction::{Transaction, TransactionKind}; + //TODO relative ("yesterday", "-2d", etc) fn parse_date(s: &str) -> Result<NaiveDate, String> { NaiveDate::parse_from_str(s, "%Y-%m-%d").map_err(|e| e.to_string()) @@ -16,7 +21,7 @@ fn parse_date(s: &str) -> Result<NaiveDate, String> { #[derive(StructOpt)] enum Command { Insert { - kind: transaction::TransactionKind, + kind: TransactionKind, #[structopt(long)] account: String, @@ -62,7 +67,13 @@ struct Mn { } fn main() { - let mut store = store::Store::open(PathBuf::from("store")).unwrap(); + let mut store = Store::open(PathBuf::from("store")).unwrap(); + + let search = Search::new(store.transactions().iter().collect()); + println!("{:?}", search.get()); + let search = search.subtract(Constraint::Category("a".to_string())); + println!("{:?}", search.get()); + let args = Mn::from_args(); eprintln!("{:?}", args); match args.command { @@ -74,7 +85,7 @@ fn main() { description, date, } => { - let transaction = transaction::Transaction { + let transaction = Transaction { kind, to: account, from: "Default".to_string(), |
