10 releases

new 0.3.5 Mar 12, 2025
0.3.4 Feb 21, 2025
0.3.2 Dec 9, 2024
0.3.1 Nov 14, 2024
0.1.0 Oct 8, 2024

#851 in Parser implementations

Download history 123/week @ 2024-11-13 10/week @ 2024-11-20 124/week @ 2024-12-04 46/week @ 2024-12-11 1/week @ 2024-12-18 1/week @ 2025-01-08 79/week @ 2025-01-29 37/week @ 2025-02-05 150/week @ 2025-02-12 213/week @ 2025-02-19 26/week @ 2025-02-26

463 downloads per month

MIT license

145KB
1.5K SLoC

cql2-cli

A Command Line Interface (CLI) for Common Query Language (CQL2).

Installation

With cargo:

cargo install cql2-cli

Or from PyPI:

pip install cql2

CLI

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

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

You can convert formats:

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

Use -v to get detailed validation information:

$ 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:

$ 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 for license and contributing information.

Dependencies

~24–32MB
~498K SLoC