Repository: developmentseed/cql2-rs (language: python)

Issue:
Add round trip back to CQL2 Text, Start output work for SQL, Add Commands
Add round trip back to CQL2 Text, Start output work for SQL, Add Commands


Discussion / hints:

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index 23ec0fa..96627ec 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -130,7 +130,6 @@ dependencies = [
  "atty",
  "boon",
  "geozero",
- "glob",
  "lazy_static",
  "pest",
  "pest_derive",
diff --git a/Cargo.toml b/Cargo.toml
index 41746ad..2960824 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,16 +3,31 @@ name = "cql2"
 version = "0.1.0"
 edition = "2021"
 
+[features]
+defaults = ["bin"]
+bin = ["dep:atty"]
+
 [dependencies]
 geozero = { git = "https://github.com/bitner/geozero.git", rev = "45828d7" }
 boon = "0.6.0"
-glob = "0.3.1"
 lazy_static = "1.5.0"
 pest = "2.7.11"
 pest_derive = "2.7.11"
-rstest = "0.21.0"
 serde = "1.0.204"
 serde_derive = "1.0.204"
 serde_json = { version = "1.0.120", features = ["preserve_order"] }
+atty = { version = "0.2.14", optional = true }
+
+[dev-dependencies]
 assert-json-diff = "2.0.2"
-atty = "0.2.14"
+rstest = "0.21.0"
+
+[[bin]]
+name = "cql2json"
+path = "src/bin/cql2json.rs"
+required-features = ["bin"]
+
+[[bin]]
+name = "cql2text"
+path = "src/bin/cql2text.rs"
+required-features = ["bin"]
diff --git a/src/lib.rs b/src/lib.rs
index 825f8fe..e4e481b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,5 @@
+#![deny(unused_crate_dependencies)]
+
 use boon::{Compiler, SchemaIndex, Schemas};
 use geozero::geojson::GeoJsonString;
 use geozero::geojson::GeoJsonWriter;
@@ -475,3 +477,9 @@ pub fn parse_file(f: &str) -> Expr {
     let cql2 = fs::read_to_string(f).unwrap();
     parse(&cql2)
 }
+
+#[cfg(test)]
+use {assert_json_diff as _, rstest as _};
+
+#[cfg(feature = "bin")]
+use atty as _;
diff --git a/src/main.rs b/src/main.rs
deleted file mode 100644
index e3498cf..0000000
--- a/src/main.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-use cql2::parse;
-use std::io::{self, BufRead};
-fn main() -> io::Result<()> {
-    for line in io::stdin().lock().lines() {
-        let parsed = parse(&line?);
-
-        println!("Parsed: {:#?}", &parsed);
-        println!("{}", parsed.as_json());
-
-        parsed.validate();
-    }
-    Ok(())
-}


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 2e57fcc..561e383 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -12,8 +12,6 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v3
-        with:
-          submodules: true
 
       - name: Install Rust
         uses: dtolnay/rust-toolchain@stable
@@ -23,15 +21,15 @@ jobs:
       - uses: Swatinem/rust-cache@v2
 
       - name: Cargo fmt
-        run: cargo fmt --all -- --check
+        run: cargo fmt -- --check
 
       - name: "clippy --all"
-        run: cargo clippy --all --all-features --tests -- -D warnings
+        run: cargo clippy --all-features --tests -- -D warnings
 
       - name: "cargo check"
-        run: cargo check --all --all-features
+        run: cargo check --all-features
 
       - name: "cargo test"
         run: |
-          cargo test --all
+          cargo test --all --no-default-features
           cargo test --all --all-features