Skip to content

Commit 8b1a75b

Browse files
committed
release: v0.1.0
We'll manually release with cargo-release (https://github.com/crate-ci/cargo-release) once merged.
1 parent 2caec3e commit 8b1a75b

File tree

6 files changed

+144
-56
lines changed

6 files changed

+144
-56
lines changed

CONTRIBUTING.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Contributing to **cql2-rs**
2+
3+
First off, thanks for contributing!
4+
We appreciates you.
5+
6+
## Testing
7+
8+
We aim for comprehensive unit testing of this library.
9+
Please provide tests for any new features, or to demonstrate bugs.
10+
Draft pull requests with a failing test to demonstrate a bug are much appreciated.
11+
12+
## Submitting changes
13+
14+
Please open a [pull request](https://docs.github.com/en/pull-requests) with your changes -- make sure to include unit tests.
15+
Please follow standard git commit formatting (subject line 50 characters max, wrap the body at 72 characters).
16+
17+
If you can, use `git rebase -i` to create a clean, well-formatted history before opening your pull request.
18+
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.
19+
20+
Thanks so much!

Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
[package]
22
name = "cql2"
33
version = "0.1.0"
4+
authors = ["David Bitner <[email protected]>"]
45
edition = "2021"
6+
description = "Parse, validate, and convert Common Query Language (CQL2) text and JSON"
7+
documentation = "https://docs.rs/cql2"
8+
readme = "README.md"
9+
homepage = "https://github.com/developmentseed/cql2-rs"
10+
repository = "https://github.com/developmentseed/cql2-rs"
11+
license = "MIT"
12+
keywords = ["cql2"]
513

614
[dependencies]
715
boon = "0.6.0"

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2024 Development Seed
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

README.md

+31-56
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,50 @@
1-
# CQL2-RS
1+
# cql2-rs
22

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

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

7-
## CLI
7+
## Usage
88

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

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

16-
You can convert formats:
16+
Then:
1717

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

23-
Use `-v` to get detailed validation information:
24-
25-
```shell
26-
$ cql2 'wrong' -v
27-
[ERROR] Invalid CQL2: wrong
28-
For more detailed validation information, use -vv
29-
jsonschema validation failed with file:///tmp/cql2.json#
30-
- at '': oneOf failed, none matched
31-
- at '': missing properties 'op', 'args'
32-
- at '': missing properties 'op', 'args'
33-
- at '': oneOf failed, none matched
34-
- at '': missing properties 'op', 'args'
35-
- at '': missing properties 'op', 'args'
36-
- at '': missing properties 'op', 'args'
37-
- at '': missing properties 'op', 'args'
38-
- at '': missing properties 'op', 'args'
39-
- at '': missing properties 'op', 'args'
40-
- at '': missing properties 'op', 'args'
41-
- at '': missing properties 'op', 'args'
42-
- at '': missing properties 'op', 'args'
43-
- at '': want boolean, but got object
21+
let expr: Expr = "landsat:scene_id = 'LC82030282019133LGN00'".parse().unwrap();
22+
assert!(expr.is_valid());
23+
println!("{}", expr.to_json().unwrap());
4424
```
4525

46-
cql2-text parsing errors are pretty-printed:
47-
48-
```shell
49-
$ cql2 '(foo ~= "bar")'
50-
[ERROR] Parsing error: (foo ~= "bar")
51-
--> 1:6
52-
|
53-
1 | (foo ~= "bar")
54-
| ^---
55-
|
56-
= expected NotFlag, And, Or, ConcatInfixOp, Add, Subtract, Multiply, Divide, Modulo, Power, Eq, Gt, GtEq, Lt, LtEq, NotEq, Is, or IsNullPostfix
57-
```
26+
See [the documentation](https://docs.rs/cql2) for more.
27+
28+
## CLI
5829

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

61-
## Response
32+
## Responses
6233

6334
Responses may not match the input.
6435

65-
### CQL2-Text Differences
36+
### cql2-text differences
6637

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

72-
Tasks to get to ready-to-use state:
73-
- [x] Parse all examples from CQL2 examples into json that passes json schema validation.
74-
- [x] Add tests that compare OGC examples to parsed/standardized/validated CQL2-Text and CQL2-JSON
75-
- [ ] Fix issues with Z, ZM, and M WKT variants
43+
## Development
44+
45+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for information about contributing to this project.
46+
47+
## License
48+
49+
**cql2-rs** is licensed under the MIT license.
50+
See [LICENSE](./LICENSE) for details.

cli/Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
[package]
22
name = "cql2-cli"
33
version = "0.1.0"
4+
authors = ["David Bitner <[email protected]>"]
45
edition = "2021"
6+
description = "Command line interface (CLI) for Common Query Language (CQL2)"
7+
readme = "README.md"
8+
homepage = "https://github.com/developmentseed/cql2-rs"
9+
repository = "https://github.com/developmentseed/cql2-rs"
10+
license = "MIT"
11+
keywords = ["cql2"]
12+
513

614
[dependencies]
715
cql2 = { path = "..", version = "0.1.0" }

cli/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# cql2-cli
2+
3+
A Command Line Interface (CLI) for [Common Query Language (CQL2)](https://www.ogc.org/standard/cql2/).
4+
5+
## Installation
6+
7+
Install [Rust](https://rustup.rs/).
8+
Then:
9+
10+
```shell
11+
cargo install cql2-cli
12+
```
13+
14+
## CLI
15+
16+
At its simplest, the CLI is a pass-through validator:
17+
18+
```shell
19+
$ cql2 < tests/fixtures/text/example01.txt # will succeed if the CQL2 is valid
20+
("landsat:scene_id" = 'LC82030282019133LGN00')
21+
```
22+
23+
You can convert formats:
24+
25+
```shell
26+
$ cql2 -o json < tests/fixtures/text/example01.txt
27+
{"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]}
28+
```
29+
30+
Use `-v` to get detailed validation information:
31+
32+
```shell
33+
$ cql2 'wrong' -v
34+
[ERROR] Invalid CQL2: wrong
35+
For more detailed validation information, use -vv
36+
jsonschema validation failed with file:///tmp/cql2.json#
37+
- at '': oneOf failed, none matched
38+
- at '': missing properties 'op', 'args'
39+
- at '': missing properties 'op', 'args'
40+
- at '': oneOf failed, none matched
41+
- at '': missing properties 'op', 'args'
42+
- at '': missing properties 'op', 'args'
43+
- at '': missing properties 'op', 'args'
44+
- at '': missing properties 'op', 'args'
45+
- at '': missing properties 'op', 'args'
46+
- at '': missing properties 'op', 'args'
47+
- at '': missing properties 'op', 'args'
48+
- at '': missing properties 'op', 'args'
49+
- at '': missing properties 'op', 'args'
50+
- at '': want boolean, but got object
51+
```
52+
53+
cql2-text parsing errors are pretty-printed:
54+
55+
```shell
56+
$ cql2 '(foo ~= "bar")'
57+
[ERROR] Parsing error: (foo ~= "bar")
58+
--> 1:6
59+
|
60+
1 | (foo ~= "bar")
61+
| ^---
62+
|
63+
= expected NotFlag, And, Or, ConcatInfixOp, Add, Subtract, Multiply, Divide, Modulo, Power, Eq, Gt, GtEq, Lt, LtEq, NotEq, Is, or IsNullPostfix
64+
```
65+
66+
Use `cql2 --help` to get a complete listing of the CLI arguments and formats.
67+
68+
## More information
69+
70+
See [the top-level README](../README.md) for license and contributing information.

0 commit comments

Comments
 (0)