aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-04-03 06:34:47 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-04-03 06:34:47 +0200
commit38b60098e42b4a899eb574f65fa14d4fdbe82f9b (patch)
tree3956fe1ab8107c5feb043fd466a969da8f5b1f9a /README.md
parentd20acec5efcad4b3cd493f914d10e3d11cdfee4d (diff)
downloadele-38b60098e42b4a899eb574f65fa14d4fdbe82f9b.tar.gz
ele-38b60098e42b4a899eb574f65fa14d4fdbe82f9b.zip
Init
Diffstat (limited to 'README.md')
-rw-r--r--README.md77
1 files changed, 77 insertions, 0 deletions
diff --git a/README.md b/README.md
index 39b3c4c..c372d84 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,78 @@
# aip-filter
+
+Parses and evaluates [AIP-160](https://google.aip.dev/160) filter expressions.
+
+## Install
+
+Clone the repository and install it with Cargo:
+
+```bash
+cargo install --path .
+```
+
+## CLI usage
+
+```bash
+usage: aip-filter [-p|--print] <expr> [file...]
+```
+
+* `--print` prints the parsed expression instead of evaluating it.
+* If no files are given, reads from stdin.
+
+### Examples
+
+```bash
+# Match if price is between 10 and 100, and status is active
+echo '{"price": 93, "status": "active"}' | \
+ aip-filter "price > 10 AND price < 100 AND status = active"
+
+# Match if 'foobar' appears in any field (bare-literal match)
+echo '{"id": 1, "msg": "hello foobar"}' | aip-filter "foobar"
+
+# Match if 'tags' contains 'beta'
+echo '{"tags": ["stable", "beta"]}' | aip-filter "tags:beta"
+
+# Nested field access
+echo '{"user": {"settings": {"theme": "dark"}}}' | \
+ aip-filter "user.settings.theme = dark"
+```
+
+## API
+
+Implement `Filterable` for your type, then call `Expr::evaluate`:
+
+```rust
+use aip_filter::{parse, Value, Filterable};
+
+struct Issue {
+ state: String,
+ priority: i64,
+ labels: Vec<String>,
+}
+
+impl Filterable for Issue {
+ fn field(&self, name: &str) -> Option<Value<'_>> {
+ match name {
+ "state" => Some(Value::String(&self.state)),
+ "priority" => Some(Value::Int(self.priority)),
+ "labels" => Some(Value::List(
+ self.labels.iter().map(|l| Value::String(l)).collect()
+ )),
+ _ => None,
+ }
+ }
+}
+
+fn main() {
+ let expr = parse("state = \"open\"").unwrap().unwrap();
+ let issue = Issue { state: "open".into(), priority: 1, labels: vec![] };
+
+ if expr.evaluate(&issue) {
+ println!("got match");
+ } else {
+ println!("no match");
+ }
+
+ assert!(expr.evaluate(&issue));
+}
+```