Skip to content

Commit

Permalink
release: v0.1.0
Browse files Browse the repository at this point in the history
We'll manually release with cargo-release
(https://github.com/crate-ci/cargo-release) once merged.
  • Loading branch information
gadomski committed Oct 8, 2024
1 parent 2caec3e commit 8b1a75b
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 56 deletions.
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contributing to **cql2-rs**

First off, thanks for contributing!
We appreciates you.

## Testing

We aim for comprehensive unit testing of this library.
Please provide tests for any new features, or to demonstrate bugs.
Draft pull requests with a failing test to demonstrate a bug are much appreciated.

## Submitting changes

Please open a [pull request](https://docs.github.com/en/pull-requests) with your changes -- make sure to include unit tests.
Please follow standard git commit formatting (subject line 50 characters max, wrap the body at 72 characters).

If you can, use `git rebase -i` to create a clean, well-formatted history before opening your pull request.
If you need to make changes after opening your pull request (e.g. to fix CI breakages) we will be grateful if you squash those fixes into their relevant commits.

Thanks so much!
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[package]
name = "cql2"
version = "0.1.0"
authors = ["David Bitner <[email protected]>"]
edition = "2021"
description = "Parse, validate, and convert Common Query Language (CQL2) text and JSON"
documentation = "https://docs.rs/cql2"
readme = "README.md"
homepage = "https://github.com/developmentseed/cql2-rs"
repository = "https://github.com/developmentseed/cql2-rs"
license = "MIT"
keywords = ["cql2"]

[dependencies]
boon = "0.6.0"
Expand Down
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Development Seed

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
87 changes: 31 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,50 @@
# CQL2-RS
# cql2-rs

## WORK IN PROGRESS, NOT READY FOR USE
[![CI](https://github.com/developmentseed/cql2-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/developmentseed/cql2-rs/actions/workflows/ci.yml)

Parse, validate, and convert CQL2-Text and CQL2-JSON.
Parse, validate, and convert [Common Query Language (CQL2)](https://www.ogc.org/standard/cql2/) text and JSON.

## CLI
## Usage

At its simplest, the command-line interface (CLI) is a pass-through validator:
### API

```shell
$ cql2 < tests/fixtures/text/example01.txt # will succeed if the CQL2 is valid
("landsat:scene_id" = 'LC82030282019133LGN00')
```toml
[dependencies]
cql = "0.1"
```

You can convert formats:
Then:

```shell
$ cql2 -o json < tests/fixtures/text/example01.txt
{"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]}
```
```rust
use cql2::Expr;

Use `-v` to get detailed validation information:

```shell
$ cql2 'wrong' -v
[ERROR] Invalid CQL2: wrong
For more detailed validation information, use -vv
jsonschema validation failed with file:///tmp/cql2.json#
- at '': oneOf failed, none matched
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': oneOf failed, none matched
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': want boolean, but got object
let expr: Expr = "landsat:scene_id = 'LC82030282019133LGN00'".parse().unwrap();
assert!(expr.is_valid());
println!("{}", expr.to_json().unwrap());
```

cql2-text parsing errors are pretty-printed:

```shell
$ cql2 '(foo ~= "bar")'
[ERROR] Parsing error: (foo ~= "bar")
--> 1:6
|
1 | (foo ~= "bar")
| ^---
|
= expected NotFlag, And, Or, ConcatInfixOp, Add, Subtract, Multiply, Divide, Modulo, Power, Eq, Gt, GtEq, Lt, LtEq, NotEq, Is, or IsNullPostfix
```
See [the documentation](https://docs.rs/cql2) for more.

## CLI

Use `cql2 --help` to get a complete listing of the CLI arguments and formats.
See [the cql-cli README](./cli/README.md) for details.

## Response
## Responses

Responses may not match the input.

### CQL2-Text Differences
### cql2-text differences

- all identifiers in output are double quoted
- position of "NOT" keywords is standardized to be before the expression (ie "... NOT LIKE ..." will become "NOT ... LIKE ..."
- The Negative operator on anything besides a literal number becomes "* -1"
- All identifiers in output are double quoted
- The position of "NOT" keywords is standardized to be before the expression (ie "... NOT LIKE ..." will become "NOT ... LIKE ..."
- The negative operator on anything besides a literal number becomes "* -1"
- Parentheses are added around all expressions

Tasks to get to ready-to-use state:
- [x] Parse all examples from CQL2 examples into json that passes json schema validation.
- [x] Add tests that compare OGC examples to parsed/standardized/validated CQL2-Text and CQL2-JSON
- [ ] Fix issues with Z, ZM, and M WKT variants
## Development

See [CONTRIBUTING.md](./CONTRIBUTING.md) for information about contributing to this project.

## License

**cql2-rs** is licensed under the MIT license.
See [LICENSE](./LICENSE) for details.
8 changes: 8 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[package]
name = "cql2-cli"
version = "0.1.0"
authors = ["David Bitner <[email protected]>"]
edition = "2021"
description = "Command line interface (CLI) for Common Query Language (CQL2)"
readme = "README.md"
homepage = "https://github.com/developmentseed/cql2-rs"
repository = "https://github.com/developmentseed/cql2-rs"
license = "MIT"
keywords = ["cql2"]


[dependencies]
cql2 = { path = "..", version = "0.1.0" }
Expand Down
70 changes: 70 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# cql2-cli

A Command Line Interface (CLI) for [Common Query Language (CQL2)](https://www.ogc.org/standard/cql2/).

## Installation

Install [Rust](https://rustup.rs/).
Then:

```shell
cargo install cql2-cli
```

## CLI

At its simplest, the CLI is a pass-through validator:

```shell
$ cql2 < tests/fixtures/text/example01.txt # will succeed if the CQL2 is valid
("landsat:scene_id" = 'LC82030282019133LGN00')
```

You can convert formats:

```shell
$ cql2 -o json < tests/fixtures/text/example01.txt
{"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]}
```

Use `-v` to get detailed validation information:

```shell
$ cql2 'wrong' -v
[ERROR] Invalid CQL2: wrong
For more detailed validation information, use -vv
jsonschema validation failed with file:///tmp/cql2.json#
- at '': oneOf failed, none matched
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': oneOf failed, none matched
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': missing properties 'op', 'args'
- at '': want boolean, but got object
```

cql2-text parsing errors are pretty-printed:

```shell
$ cql2 '(foo ~= "bar")'
[ERROR] Parsing error: (foo ~= "bar")
--> 1:6
|
1 | (foo ~= "bar")
| ^---
|
= expected NotFlag, And, Or, ConcatInfixOp, Add, Subtract, Multiply, Divide, Modulo, Power, Eq, Gt, GtEq, Lt, LtEq, NotEq, Is, or IsNullPostfix
```

Use `cql2 --help` to get a complete listing of the CLI arguments and formats.

## More information

See [the top-level README](../README.md) for license and contributing information.

0 comments on commit 8b1a75b

Please sign in to comment.