summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/Cargo.lock77
-rw-r--r--cli/Cargo.toml1
-rw-r--r--cli/src/search.rs27
3 files changed, 104 insertions, 1 deletions
diff --git a/cli/Cargo.lock b/cli/Cargo.lock
index 2a8bac4..2bc65b9 100644
--- a/cli/Cargo.lock
+++ b/cli/Cargo.lock
@@ -41,12 +41,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
+name = "bitvec"
+version = "0.19.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321"
+dependencies = [
+ "funty",
+ "radium",
+ "tap",
+ "wyz",
+]
+
+[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -76,6 +94,12 @@ dependencies = [
]
[[package]]
+name = "funty"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
+
+[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -106,16 +130,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
+name = "lexical-core"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
+dependencies = [
+ "arrayvec",
+ "bitflags",
+ "cfg-if 1.0.0",
+ "ryu",
+ "static_assertions",
+]
+
+[[package]]
name = "libc"
version = "0.2.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
[[package]]
+name = "memchr"
+version = "2.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
+
+[[package]]
name = "money-cli"
version = "0.1.0"
dependencies = [
"chrono",
+ "nom",
"rust_decimal",
"serde",
"serde_json",
@@ -125,6 +169,19 @@ dependencies = [
]
[[package]]
+name = "nom"
+version = "6.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c5c51b9083a3c620fa67a2a635d1ce7d95b897e957d6b28ff9a5da960a103a6"
+dependencies = [
+ "bitvec",
+ "funty",
+ "lexical-core",
+ "memchr",
+ "version_check",
+]
+
+[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -195,6 +252,12 @@ dependencies = [
]
[[package]]
+name = "radium"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
+
+[[package]]
name = "rust_decimal"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -312,6 +375,12 @@ dependencies = [
]
[[package]]
+name = "tap"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
+
+[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -336,7 +405,7 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"static_assertions",
]
@@ -391,3 +460,9 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "wyz"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index e64608e..6f273aa 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
chrono = { version = "0.4.19", features = ["serde"] }
+nom = "6.2.1"
rust_decimal = { version = "1.15.0", features = ["serde-arbitrary-precision"] }
serde = { version = "1.0.126", features = ["derive"] }
serde_json = "1.0.64"
diff --git a/cli/src/search.rs b/cli/src/search.rs
index d140caf..b11ee78 100644
--- a/cli/src/search.rs
+++ b/cli/src/search.rs
@@ -1,4 +1,5 @@
use chrono::{naive::NaiveDate, Duration};
+use nom::{branch::alt, character::complete::char, combinator::map, sequence::tuple};
use rust_decimal::Decimal;
use std::str::FromStr;
@@ -98,6 +99,10 @@ impl Constraint {
}
}
}
+
+ fn parse(i: &str) -> nom::IResult<&str, Self> {
+ todo!()
+ }
}
#[derive(Clone)]
@@ -107,6 +112,28 @@ pub enum Filter {
Subtract(Constraint),
}
+impl Filter {
+ fn parse(i: &str) -> nom::IResult<&str, Self> {
+ alt((
+ map(
+ tuple((
+ char('+'),
+ Constraint::parse,
+ )),
+ |(_, constraint)| Filter::Union(constraint)
+ ),
+ map(
+ tuple((
+ char('-'),
+ Constraint::parse,
+ )),
+ |(_, constraint)| Filter::Subtract(constraint)
+ ),
+ map(Constraint::parse, Filter::Intersect),
+ ))(i)
+ }
+}
+
#[derive(Clone)]
pub struct Search<'t> {
filtered: Vec<usize>,