celq 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- celq-0.3.1/CHANGELOG.md +63 -0
- {celq-0.3.0 → celq-0.3.1}/Cargo.lock +1 -1
- {celq-0.3.0 → celq-0.3.1}/Cargo.toml +2 -1
- {celq-0.3.0 → celq-0.3.1}/PKG-INFO +36 -30
- {celq-0.3.0 → celq-0.3.1}/README.md +35 -29
- {celq-0.3.0 → celq-0.3.1}/docs/installation_guide.md +42 -27
- {celq-0.3.0 → celq-0.3.1}/docs/manual.md +36 -17
- {celq-0.3.0 → celq-0.3.1}/pypi/README.md +35 -29
- {celq-0.3.0 → celq-0.3.1}/src/cli.rs +1 -2
- {celq-0.3.0 → celq-0.3.1}/src/input_handler.rs +1 -2
- {celq-0.3.0 → celq-0.3.1}/src/main.rs +0 -2
- {celq-0.3.0 → celq-0.3.1}/tests/golden.rs +8 -0
- celq-0.3.0/src/cel2json.rs +0 -53
- {celq-0.3.0 → celq-0.3.1}/LICENSE-APACHE +0 -0
- {celq-0.3.0 → celq-0.3.1}/LICENSE-MIT +0 -0
- {celq-0.3.0 → celq-0.3.1}/docs/comparison_with_other_tools.md +0 -0
- {celq-0.3.0 → celq-0.3.1}/pypi/LICENSE-APACHE +0 -0
- {celq-0.3.0 → celq-0.3.1}/pypi/LICENSE-MIT +0 -0
- {celq-0.3.0 → celq-0.3.1}/pyproject.toml +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/args2cel.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/args2cel_test.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/documentation.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/gron.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/gron_test.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/input_handler_test.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/json2cel.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/json2cel_test.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/slice_extension.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/ungron.rs +0 -0
- {celq-0.3.0 → celq-0.3.1}/src/ungron_test.rs +0 -0
celq-0.3.1/CHANGELOG.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Changelog
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
[v0.3.1](https://github.com/IvanIsCoding/celq/releases/tag/v0.3.1) - 2026-01-27
|
|
5
|
+
|
|
6
|
+
### Added
|
|
7
|
+
|
|
8
|
+
* Added the `--verify-checksum` flag to `install.sh`
|
|
9
|
+
* `celq` now returns the input if no expression is passed
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
[v0.3.0](https://github.com/IvanIsCoding/celq/releases/tag/v0.3.0) - 2026-01-24
|
|
13
|
+
------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
* Added pre-compiled FreeBSD aarch64 binaries
|
|
18
|
+
* Added support for parallelism when using the `--slurp` flag with the `-j` flag
|
|
19
|
+
|
|
20
|
+
### Miscellaneous
|
|
21
|
+
|
|
22
|
+
* Bumped the YAML parser to incorporate fixes (`serde-saphyr` -> 0.0.16)
|
|
23
|
+
* Bumped the JSON5 parser to incorporate fixes (`json5` -> 1.3.0)
|
|
24
|
+
* Bumped the MSRV to Rust 1.91
|
|
25
|
+
|
|
26
|
+
[v0.2.0](https://github.com/IvanIsCoding/celq/releases/tag/v0.2.0) - 2026-01-17
|
|
27
|
+
------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
* Added support for array slicing (e.g. `this.slice(a, b)`)
|
|
32
|
+
* Added support for TOML inputs with `--from-toml`
|
|
33
|
+
* Added support for YAML inputs with `--from-yaml`
|
|
34
|
+
* Added support for greppable json inspired by `gron`
|
|
35
|
+
* Added pre-compiled FreeBSD x86-64 binaries
|
|
36
|
+
* Added pre-built binaries via Scoop for Windows
|
|
37
|
+
|
|
38
|
+
### Miscellaneous
|
|
39
|
+
|
|
40
|
+
* Live Playground: https://celq-playground.github.io/
|
|
41
|
+
* Switched PyPI releases to use Zig for linking
|
|
42
|
+
* Switched pre-built binaries to prettified names (e.g. `celq-macos-aarch64.tar.gz` instead of `celq-aarch64-apple-darwin.tar.gz`)
|
|
43
|
+
|
|
44
|
+
[v0.1.1](https://github.com/IvanIsCoding/celq/releases/tag/v0.1.1) - 2026-01-06
|
|
45
|
+
------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
|
|
49
|
+
* Added pre-built binaries via GitHub releases
|
|
50
|
+
* Added pre-built binaries via PyPI
|
|
51
|
+
* Added pre-built binaries via NPM
|
|
52
|
+
* Added pre-built binaries via Chocolatey for Windows
|
|
53
|
+
* Added pre-built binaries via Homebrew for Mac
|
|
54
|
+
* Published Nix support with and without flakes
|
|
55
|
+
|
|
56
|
+
### Miscellaneous
|
|
57
|
+
|
|
58
|
+
* Many documentation updates.
|
|
59
|
+
|
|
60
|
+
[v0.1.0](https://github.com/IvanIsCoding/celq/releases/tag/v0.1.0) - 2026-01-04
|
|
61
|
+
------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
Initial release with support for JSON and JSON5!
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "celq"
|
|
3
3
|
description = "A CEL command-line query tool for JSON data"
|
|
4
|
-
version = "0.3.
|
|
4
|
+
version = "0.3.1"
|
|
5
5
|
edition = "2024"
|
|
6
6
|
rust-version = "1.91"
|
|
7
7
|
authors = ["Ivan Carvalho <ivancarvalho@gatech.edu>"]
|
|
@@ -20,6 +20,7 @@ include = [
|
|
|
20
20
|
"README.md",
|
|
21
21
|
"LICENSE-MIT",
|
|
22
22
|
"LICENSE-APACHE",
|
|
23
|
+
"CHANGELOG.md",
|
|
23
24
|
]
|
|
24
25
|
readme = "README.md"
|
|
25
26
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: celq
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Classifier: Intended Audience :: Developers
|
|
5
5
|
Classifier: Programming Language :: Rust
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
@@ -119,33 +119,6 @@ If you have [cargo-binstall](https://github.com/cargo-bins/cargo-binstall) insta
|
|
|
119
119
|
cargo binstall celq
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
### Python
|
|
123
|
-
|
|
124
|
-
celq is packaged for [PyPI](https://pypi.org/project/celq/). Python users can install it with `pip`:
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
pip install celq
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used as a tool:
|
|
131
|
-
```bash
|
|
132
|
-
uvx celq -n '"Hello World"'
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### NPM (Node.js/JavaScript)
|
|
136
|
-
|
|
137
|
-
`celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
npm install celq
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
This adds celq to `package.json` and makes it available for scripts. It's also possible to run single commands with [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
npx celq -n '"Hello World"'
|
|
147
|
-
```
|
|
148
|
-
|
|
149
122
|
### GitHub Actions
|
|
150
123
|
|
|
151
124
|
`celq` can be used in GitHub actions. For one-off commands, the [get-celq/celq-action](https://github.com/get-celq/celq-action) is the quickest way:
|
|
@@ -179,6 +152,12 @@ If you are going to use `celq` in scripts or for multiple calls, we recommend us
|
|
|
179
152
|
nix run github:IvanIsCoding/celq -- -n '"Hello World"'
|
|
180
153
|
```
|
|
181
154
|
|
|
155
|
+
By default, Nix fetches the stable version from crates.io. If you want to run the code from HEAD, use the `dev` derivation:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
nix run github:IvanIsCoding/celq#dev -- -n '"Hello World"'
|
|
159
|
+
```
|
|
160
|
+
|
|
182
161
|
See the [installation guide](https://docs.rs/celq/latest/celq/installation_guide) for other Nix setups.
|
|
183
162
|
|
|
184
163
|
### FreeBSD
|
|
@@ -198,13 +177,40 @@ su root -c 'install -m 755 celq /usr/local/bin/'
|
|
|
198
177
|
|
|
199
178
|
`celq` can also be installed from source following the [Cargo](#cargo) section. We strive to always compile with the Rust version provided in the ports tree.
|
|
200
179
|
|
|
180
|
+
### NPM (Node.js/JavaScript)
|
|
181
|
+
|
|
182
|
+
`celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npm install celq
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
This adds celq to `package.json` and makes it available for scripts. It's also possible to run single commands with [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npx celq -n '"Hello World"'
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Python
|
|
195
|
+
|
|
196
|
+
celq is packaged for [PyPI](https://pypi.org/project/celq/). Python users can install it with `pip`:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
pip install celq
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used as a tool:
|
|
203
|
+
```bash
|
|
204
|
+
uvx celq -n '"Hello World"'
|
|
205
|
+
```
|
|
206
|
+
|
|
201
207
|
## Limitations
|
|
202
208
|
|
|
203
209
|
### Eager JSON Parsing
|
|
204
210
|
|
|
205
211
|
`celq` eagerly parses all JSON input into memory before evaluation. This design was made to simplify the code implementation, at the cost of memory and performance.
|
|
206
212
|
|
|
207
|
-
Currently, there are no benchmarks for `celq`. I believe the tool is "good enough" for my personal use. That might be revisited in the future. In the meantime, expect `celq` to be slower than `jq`.
|
|
213
|
+
Currently, there are no benchmarks for `celq`. I believe the tool is "good enough" for my personal use. That might be revisited in the future. In the meantime, expect `celq` to be slower than `jq`. With that being said, `celq` feels snappy in practice. `celq` glues together Rust parsers that are performant with a CEL engine that strives to be fast.
|
|
208
214
|
|
|
209
215
|
### CEL Implementation Differences
|
|
210
216
|
|
|
@@ -240,7 +246,7 @@ Special thanks to the maintainers of:
|
|
|
240
246
|
|
|
241
247
|
## Large Language Models Disclosure
|
|
242
248
|
|
|
243
|
-
Many commits in this repository were co-authored by LLMs. All commits were guided and reviewed by a human.
|
|
249
|
+
Many commits in this repository were co-authored by LLMs. All commits were guided and reviewed by a human. I tried my best to keep things simple and auditable.
|
|
244
250
|
|
|
245
251
|
All the documentation in the manual has been hand-crafted. That was done to keep the tone of the original author. If you find a typo or a grammar mistake, please send a pull request.
|
|
246
252
|
|
|
@@ -98,33 +98,6 @@ If you have [cargo-binstall](https://github.com/cargo-bins/cargo-binstall) insta
|
|
|
98
98
|
cargo binstall celq
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
### Python
|
|
102
|
-
|
|
103
|
-
celq is packaged for [PyPI](https://pypi.org/project/celq/). Python users can install it with `pip`:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
pip install celq
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used as a tool:
|
|
110
|
-
```bash
|
|
111
|
-
uvx celq -n '"Hello World"'
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### NPM (Node.js/JavaScript)
|
|
115
|
-
|
|
116
|
-
`celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
npm install celq
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
This adds celq to `package.json` and makes it available for scripts. It's also possible to run single commands with [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
npx celq -n '"Hello World"'
|
|
126
|
-
```
|
|
127
|
-
|
|
128
101
|
### GitHub Actions
|
|
129
102
|
|
|
130
103
|
`celq` can be used in GitHub actions. For one-off commands, the [get-celq/celq-action](https://github.com/get-celq/celq-action) is the quickest way:
|
|
@@ -158,6 +131,12 @@ If you are going to use `celq` in scripts or for multiple calls, we recommend us
|
|
|
158
131
|
nix run github:IvanIsCoding/celq -- -n '"Hello World"'
|
|
159
132
|
```
|
|
160
133
|
|
|
134
|
+
By default, Nix fetches the stable version from crates.io. If you want to run the code from HEAD, use the `dev` derivation:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
nix run github:IvanIsCoding/celq#dev -- -n '"Hello World"'
|
|
138
|
+
```
|
|
139
|
+
|
|
161
140
|
See the [installation guide](https://docs.rs/celq/latest/celq/installation_guide) for other Nix setups.
|
|
162
141
|
|
|
163
142
|
### FreeBSD
|
|
@@ -177,13 +156,40 @@ su root -c 'install -m 755 celq /usr/local/bin/'
|
|
|
177
156
|
|
|
178
157
|
`celq` can also be installed from source following the [Cargo](#cargo) section. We strive to always compile with the Rust version provided in the ports tree.
|
|
179
158
|
|
|
159
|
+
### NPM (Node.js/JavaScript)
|
|
160
|
+
|
|
161
|
+
`celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npm install celq
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This adds celq to `package.json` and makes it available for scripts. It's also possible to run single commands with [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
npx celq -n '"Hello World"'
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Python
|
|
174
|
+
|
|
175
|
+
celq is packaged for [PyPI](https://pypi.org/project/celq/). Python users can install it with `pip`:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install celq
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used as a tool:
|
|
182
|
+
```bash
|
|
183
|
+
uvx celq -n '"Hello World"'
|
|
184
|
+
```
|
|
185
|
+
|
|
180
186
|
## Limitations
|
|
181
187
|
|
|
182
188
|
### Eager JSON Parsing
|
|
183
189
|
|
|
184
190
|
`celq` eagerly parses all JSON input into memory before evaluation. This design was made to simplify the code implementation, at the cost of memory and performance.
|
|
185
191
|
|
|
186
|
-
Currently, there are no benchmarks for `celq`. I believe the tool is "good enough" for my personal use. That might be revisited in the future. In the meantime, expect `celq` to be slower than `jq`.
|
|
192
|
+
Currently, there are no benchmarks for `celq`. I believe the tool is "good enough" for my personal use. That might be revisited in the future. In the meantime, expect `celq` to be slower than `jq`. With that being said, `celq` feels snappy in practice. `celq` glues together Rust parsers that are performant with a CEL engine that strives to be fast.
|
|
187
193
|
|
|
188
194
|
### CEL Implementation Differences
|
|
189
195
|
|
|
@@ -219,7 +225,7 @@ Special thanks to the maintainers of:
|
|
|
219
225
|
|
|
220
226
|
## Large Language Models Disclosure
|
|
221
227
|
|
|
222
|
-
Many commits in this repository were co-authored by LLMs. All commits were guided and reviewed by a human.
|
|
228
|
+
Many commits in this repository were co-authored by LLMs. All commits were guided and reviewed by a human. I tried my best to keep things simple and auditable.
|
|
223
229
|
|
|
224
230
|
All the documentation in the manual has been hand-crafted. That was done to keep the tone of the original author. If you find a typo or a grammar mistake, please send a pull request.
|
|
225
231
|
|
|
@@ -86,33 +86,6 @@ If you have [cargo-binstall](https://github.com/cargo-bins/cargo-binstall) insta
|
|
|
86
86
|
cargo binstall celq
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
### Python
|
|
90
|
-
|
|
91
|
-
celq is packaged for [PyPI](https://pypi.org/project/celq/). Python users can install it with `pip`:
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
pip install celq
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used as a tool:
|
|
98
|
-
```bash
|
|
99
|
-
uvx celq -n '"Hello World"'
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### NPM (Node.js/JavaScript)
|
|
103
|
-
|
|
104
|
-
`celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
npm install celq
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
This adds celq to `package.json` and makes it available for scripts. It's also possible to run single commands with [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
npx celq -n '"Hello World"'
|
|
114
|
-
```
|
|
115
|
-
|
|
116
89
|
### GitHub Actions
|
|
117
90
|
|
|
118
91
|
`celq` can be used in GitHub actions. For one-off commands, the [get-celq/celq-action](https://github.com/get-celq/celq-action) is the quickest way:
|
|
@@ -161,6 +134,12 @@ If you are going to use `celq` in scripts or for multiple calls, we recommend us
|
|
|
161
134
|
nix run github:IvanIsCoding/celq -- -n '"Hello World"'
|
|
162
135
|
```
|
|
163
136
|
|
|
137
|
+
By default, Nix fetches the stable version from crates.io. If you want to run the code from HEAD, use the `dev` derivation:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
nix run github:IvanIsCoding/celq#dev -- -n '"Hello World"'
|
|
141
|
+
```
|
|
142
|
+
|
|
164
143
|
We also include a `default.nix` for non-Flake users:
|
|
165
144
|
|
|
166
145
|
```bash
|
|
@@ -187,10 +166,44 @@ su root -c 'install -m 755 celq /usr/local/bin/'
|
|
|
187
166
|
|
|
188
167
|
`celq` can also be installed from source following the [Cargo](#cargo) section. We strive to always compile with the Rust version provided in the ports tree.
|
|
189
168
|
|
|
169
|
+
### NPM (Node.js/JavaScript)
|
|
170
|
+
|
|
171
|
+
`celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm install celq
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
This adds celq to `package.json` and makes it available for scripts. It's also possible to run single commands with [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npx celq -n '"Hello World"'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Python
|
|
184
|
+
|
|
185
|
+
celq is packaged for [PyPI](https://pypi.org/project/celq/). Python users can install it with `pip`:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pip install celq
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used as a tool:
|
|
192
|
+
```bash
|
|
193
|
+
uvx celq -n '"Hello World"'
|
|
194
|
+
```
|
|
195
|
+
|
|
190
196
|
## Integrity and Authenticity
|
|
191
197
|
|
|
192
198
|
`celq` publishes a `SHA256SUMS` file for each of its release in the [GitHub Releases page](https://github.com/IvanIsCoding/celq/releases). The checksum can be used to verify integrity of the downloaded files.
|
|
193
199
|
|
|
200
|
+
The `celq` installer supports the `--verify-checksum` flag to ensure the integrity of the pre-built binaries:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
curl --proto '=https' --tlsv1.2 -sSf https://get-celq.github.io/install.sh | \
|
|
204
|
+
bash -s -- --verify-checksum
|
|
205
|
+
```
|
|
206
|
+
|
|
194
207
|
`celq` also generates [artifact attestations](https://github.com/IvanIsCoding/celq/attestations) for each file in the Releases page, including the installer. To verify the authenticity of a file, use the [GitHub CLI](https://cli.github.com/) with the following command:
|
|
195
208
|
|
|
196
209
|
```bash
|
|
@@ -212,6 +225,8 @@ bash install.sh --verify-attestation
|
|
|
212
225
|
|
|
213
226
|
This way, you can guarantee that both the installer and the downloaded binaries are authentic.
|
|
214
227
|
|
|
228
|
+
Running the installer with the `--verify-checksum` requires either `sha256sum` or `shasum` to be available. If none of these tools is available, the installer will fail.
|
|
229
|
+
|
|
215
230
|
Running the installer with the `--verify-attestation` requires the GitHub CLI (`gh`). If `gh` is not found, the script will fail. If the user is not authenticated (`gh auth login`), the option will also fail. For scripts and non-interactive environments like CI, `gh auth login --with-token $GITHUB` is an option for authenticaitng when using this installer feature.
|
|
216
231
|
|
|
217
232
|
## Shell Script Installer Quirks
|
|
@@ -141,6 +141,7 @@ This file contains the simplified response from the Yahoo Finance Unofficial JSO
|
|
|
141
141
|
### Table of Contents
|
|
142
142
|
|
|
143
143
|
* [Reading Files](#reading-files)
|
|
144
|
+
* [this keyword](#this-keyword)
|
|
144
145
|
* [Writing Files](#writing-files)
|
|
145
146
|
* [Output JSON](#output-json)
|
|
146
147
|
* [Slicing lists](#slicing-lists)
|
|
@@ -175,6 +176,24 @@ cat yfinance.json | celq "this.chart.result[0].meta.symbol"
|
|
|
175
176
|
|
|
176
177
|
Both command outputs: `"AAPL"`.
|
|
177
178
|
|
|
179
|
+
### this keyword
|
|
180
|
+
|
|
181
|
+
`celq` can access the input in CEL expressions with the `this` keyword. For example:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
echo '["apples", "bananas", "blueberry"]' | celq 'this[1]'
|
|
185
|
+
# Outputs: "bananas"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
If we take the array of fruits is the input, `this[1]` refers to the element in index 1 of the input. In this case, `"bananas"`.
|
|
189
|
+
|
|
190
|
+
If no CEL expression is provided, `celq` outputs the input:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
echo '["apples", "bananas", "blueberry"]' | celq
|
|
194
|
+
# Outputs: ["apples", "bananas", "blueberry"]
|
|
195
|
+
```
|
|
196
|
+
|
|
178
197
|
### Writing Files
|
|
179
198
|
|
|
180
199
|
`celq` writes by default to the standard output. That output can be piped to a file.
|
|
@@ -204,19 +223,6 @@ Notice that by default `celq` does not guarantee the key order of the output. If
|
|
|
204
223
|
cat yfinance.json | celq --sort-keys '{"symbol": this.chart.result[0].meta.longName, "price": this.chart.result[0].meta.regularMarketPrice}'
|
|
205
224
|
```
|
|
206
225
|
|
|
207
|
-
### Slicing lists
|
|
208
|
-
|
|
209
|
-
`celq` implements the popular slice extension for CEL. For example:
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
echo '["apples", "bananas", "blueberry"]' | celq 'this.slice(1, 3)'
|
|
213
|
-
# Outputs: ["bananas", "blueberry"]
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
Slicing follows Python conventions: it is 0-indexed and works with negative indices. The `.slice()` calls always requires two arguments. If you need to slice until the end of the list, do `this.slice(pos, size(this.slice))`. Similarly, do `this.slice(0, pos)` to start from the beginning.
|
|
217
|
-
|
|
218
|
-
If you want to keep your CEL code portable, pass the `--no-extensions` arguments to disable slicing and all other extensions.
|
|
219
|
-
|
|
220
226
|
### Reading CEL from a file
|
|
221
227
|
|
|
222
228
|
In the previous example, the CEL expression for the JSON became long. Let's say we saved the expression in `stock.cel` with the following contents:
|
|
@@ -234,6 +240,19 @@ If we pass the `--from-file` argument, we can load the expression and keep the c
|
|
|
234
240
|
cat yfinance.json | celq --from-file stock.cel
|
|
235
241
|
```
|
|
236
242
|
|
|
243
|
+
### Slicing lists
|
|
244
|
+
|
|
245
|
+
`celq` implements the popular slice extension for CEL. For example:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
echo '["apples", "bananas", "blueberry"]' | celq 'this.slice(1, 3)'
|
|
249
|
+
# Outputs: ["bananas", "blueberry"]
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Slicing follows Python conventions: it is 0-indexed and works with negative indices. The `.slice()` calls always requires two arguments. If you need to slice until the end of the list, do `this.slice(pos, size(this.slice))`. Similarly, do `this.slice(0, pos)` to start from the beginning.
|
|
253
|
+
|
|
254
|
+
If you want to keep your CEL code portable, pass the `--no-extensions` arguments to disable slicing and all other extensions.
|
|
255
|
+
|
|
237
256
|
### Dealing with NDJSON
|
|
238
257
|
|
|
239
258
|
`celq` can deal with [Newline-Delimited JSON (NDJSON)](https://web.archive.org/web/20231218162511/https://ndjson.org/). That format is also called [JSON Lines (JSONL)](https://web.archive.org/web/20251130123805/https://jsonlines.org./).
|
|
@@ -432,7 +451,7 @@ celq --from-yaml 'this[1].tags' < multi.yaml
|
|
|
432
451
|
With that being said, `celq` can pretty-print JSON via the `-p` flag:
|
|
433
452
|
|
|
434
453
|
```bash
|
|
435
|
-
echo '{"a": 1, "b": 2}' | celq -p
|
|
454
|
+
echo '{"a": 1, "b": 2}' | celq -p
|
|
436
455
|
```
|
|
437
456
|
|
|
438
457
|
Outputs:
|
|
@@ -467,7 +486,7 @@ grocery_list_cli --item $FRUIT --quantity 5
|
|
|
467
486
|
|
|
468
487
|
For example, to chain `celq` with ripgrep to find all fields containing `regularMarket`:
|
|
469
488
|
```bash
|
|
470
|
-
celq -g
|
|
489
|
+
celq -g < yfinance.json | rg '\bregularMarket\w*'
|
|
471
490
|
```
|
|
472
491
|
|
|
473
492
|
Outputs:
|
|
@@ -481,7 +500,7 @@ json.chart.result[0].meta.regularMarketTime = 1767387600;
|
|
|
481
500
|
One interesting property about `--greppable` is that the output is valid JavaScript code. This unlocks use cases such as embedding TOML, YAML, and JSON5 configs as JavaScript source code. For example:
|
|
482
501
|
|
|
483
502
|
```bash
|
|
484
|
-
celq --from-toml -g -S
|
|
503
|
+
celq --from-toml -g -S < Cargo.toml > cargo_toml.js
|
|
485
504
|
```
|
|
486
505
|
|
|
487
506
|
Writes the following to `cargo_toml.js`:
|
|
@@ -506,7 +525,7 @@ For NDJSON inputs, `--greppable` outputs only the last line. This happens to pre
|
|
|
506
525
|
For example:
|
|
507
526
|
|
|
508
527
|
```bash
|
|
509
|
-
celq -g
|
|
528
|
+
celq -g < yfinance.json | rg '\bregularMarket\w*' | celq --from-gron -S -p
|
|
510
529
|
```
|
|
511
530
|
|
|
512
531
|
Outputs:
|
|
@@ -98,33 +98,6 @@ If you have [cargo-binstall](https://github.com/cargo-bins/cargo-binstall) insta
|
|
|
98
98
|
cargo binstall celq
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
### Python
|
|
102
|
-
|
|
103
|
-
celq is packaged for [PyPI](https://pypi.org/project/celq/). Python users can install it with `pip`:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
pip install celq
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used as a tool:
|
|
110
|
-
```bash
|
|
111
|
-
uvx celq -n '"Hello World"'
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### NPM (Node.js/JavaScript)
|
|
115
|
-
|
|
116
|
-
`celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
npm install celq
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
This adds celq to `package.json` and makes it available for scripts. It's also possible to run single commands with [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
npx celq -n '"Hello World"'
|
|
126
|
-
```
|
|
127
|
-
|
|
128
101
|
### GitHub Actions
|
|
129
102
|
|
|
130
103
|
`celq` can be used in GitHub actions. For one-off commands, the [get-celq/celq-action](https://github.com/get-celq/celq-action) is the quickest way:
|
|
@@ -158,6 +131,12 @@ If you are going to use `celq` in scripts or for multiple calls, we recommend us
|
|
|
158
131
|
nix run github:IvanIsCoding/celq -- -n '"Hello World"'
|
|
159
132
|
```
|
|
160
133
|
|
|
134
|
+
By default, Nix fetches the stable version from crates.io. If you want to run the code from HEAD, use the `dev` derivation:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
nix run github:IvanIsCoding/celq#dev -- -n '"Hello World"'
|
|
138
|
+
```
|
|
139
|
+
|
|
161
140
|
See the [installation guide](https://docs.rs/celq/latest/celq/installation_guide) for other Nix setups.
|
|
162
141
|
|
|
163
142
|
### FreeBSD
|
|
@@ -177,13 +156,40 @@ su root -c 'install -m 755 celq /usr/local/bin/'
|
|
|
177
156
|
|
|
178
157
|
`celq` can also be installed from source following the [Cargo](#cargo) section. We strive to always compile with the Rust version provided in the ports tree.
|
|
179
158
|
|
|
159
|
+
### NPM (Node.js/JavaScript)
|
|
160
|
+
|
|
161
|
+
`celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npm install celq
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This adds celq to `package.json` and makes it available for scripts. It's also possible to run single commands with [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
npx celq -n '"Hello World"'
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Python
|
|
174
|
+
|
|
175
|
+
celq is packaged for [PyPI](https://pypi.org/project/celq/). Python users can install it with `pip`:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install celq
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used as a tool:
|
|
182
|
+
```bash
|
|
183
|
+
uvx celq -n '"Hello World"'
|
|
184
|
+
```
|
|
185
|
+
|
|
180
186
|
## Limitations
|
|
181
187
|
|
|
182
188
|
### Eager JSON Parsing
|
|
183
189
|
|
|
184
190
|
`celq` eagerly parses all JSON input into memory before evaluation. This design was made to simplify the code implementation, at the cost of memory and performance.
|
|
185
191
|
|
|
186
|
-
Currently, there are no benchmarks for `celq`. I believe the tool is "good enough" for my personal use. That might be revisited in the future. In the meantime, expect `celq` to be slower than `jq`.
|
|
192
|
+
Currently, there are no benchmarks for `celq`. I believe the tool is "good enough" for my personal use. That might be revisited in the future. In the meantime, expect `celq` to be slower than `jq`. With that being said, `celq` feels snappy in practice. `celq` glues together Rust parsers that are performant with a CEL engine that strives to be fast.
|
|
187
193
|
|
|
188
194
|
### CEL Implementation Differences
|
|
189
195
|
|
|
@@ -219,7 +225,7 @@ Special thanks to the maintainers of:
|
|
|
219
225
|
|
|
220
226
|
## Large Language Models Disclosure
|
|
221
227
|
|
|
222
|
-
Many commits in this repository were co-authored by LLMs. All commits were guided and reviewed by a human.
|
|
228
|
+
Many commits in this repository were co-authored by LLMs. All commits were guided and reviewed by a human. I tried my best to keep things simple and auditable.
|
|
223
229
|
|
|
224
230
|
All the documentation in the manual has been hand-crafted. That was done to keep the tone of the original author. If you find a typo or a grammar mistake, please send a pull request.
|
|
225
231
|
|
|
@@ -77,7 +77,6 @@ impl std::str::FromStr for Argument {
|
|
|
77
77
|
long_about = None,
|
|
78
78
|
group(
|
|
79
79
|
ArgGroup::new("program")
|
|
80
|
-
.required(true)
|
|
81
80
|
.args(&["expression", "from_file"])
|
|
82
81
|
),
|
|
83
82
|
group(
|
|
@@ -173,7 +172,7 @@ pub struct Cli {
|
|
|
173
172
|
pub no_extensions: bool,
|
|
174
173
|
|
|
175
174
|
/// CEL expression to evaluate
|
|
176
|
-
#[arg(value_name = "expr")]
|
|
175
|
+
#[arg(value_name = "expr", default_value = "this")]
|
|
177
176
|
pub expression: Option<String>,
|
|
178
177
|
}
|
|
179
178
|
|
|
@@ -14,7 +14,6 @@ use std::io::{self};
|
|
|
14
14
|
|
|
15
15
|
use crate::InputFormat;
|
|
16
16
|
use crate::InputParameters;
|
|
17
|
-
use crate::cel_value_to_json_value;
|
|
18
17
|
use crate::json_to_cel_variables;
|
|
19
18
|
use crate::slice_extension;
|
|
20
19
|
|
|
@@ -222,7 +221,7 @@ fn handle_json(
|
|
|
222
221
|
}
|
|
223
222
|
|
|
224
223
|
fn handle_json_output(result: &CelValue, input_params: &InputParameters) -> Result<String> {
|
|
225
|
-
let mut json_value =
|
|
224
|
+
let mut json_value = result.json().map_err(|e| anyhow::anyhow!(e.to_string()))?;
|
|
226
225
|
|
|
227
226
|
if input_params.sort_keys {
|
|
228
227
|
sort_keys_recursive(&mut json_value);
|
|
@@ -9,14 +9,12 @@ use std::path::PathBuf;
|
|
|
9
9
|
use std::process;
|
|
10
10
|
|
|
11
11
|
mod args2cel;
|
|
12
|
-
mod cel2json;
|
|
13
12
|
mod cli;
|
|
14
13
|
mod input_handler;
|
|
15
14
|
mod json2cel;
|
|
16
15
|
pub mod slice_extension;
|
|
17
16
|
|
|
18
17
|
use args2cel::args_to_cel_variables;
|
|
19
|
-
pub use cel2json::cel_value_to_json_value;
|
|
20
18
|
pub use cli::Argument;
|
|
21
19
|
use cli::Cli;
|
|
22
20
|
pub use cli::InputFormat;
|
|
@@ -893,6 +893,14 @@ test!(
|
|
|
893
893
|
"[10,15,20]"
|
|
894
894
|
);
|
|
895
895
|
|
|
896
|
+
// Default expr test
|
|
897
|
+
test!(
|
|
898
|
+
default_expression,
|
|
899
|
+
&[],
|
|
900
|
+
r#"{"value":100}"#,
|
|
901
|
+
r#"{"value":100}"#
|
|
902
|
+
);
|
|
903
|
+
|
|
896
904
|
#[test]
|
|
897
905
|
fn test_boolean_false_exit_code() -> io::Result<()> {
|
|
898
906
|
let mut child = process::Command::new(env!("CARGO_BIN_EXE_celq"))
|
celq-0.3.0/src/cel2json.rs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
use cel::objects::Key;
|
|
2
|
-
use cel::objects::Value as CelValue;
|
|
3
|
-
use serde_json::Value as JsonValue;
|
|
4
|
-
|
|
5
|
-
/// Convert a CEL value to a serde_json::Value
|
|
6
|
-
pub fn cel_value_to_json_value(value: &CelValue) -> JsonValue {
|
|
7
|
-
match value {
|
|
8
|
-
CelValue::Null => JsonValue::Null,
|
|
9
|
-
|
|
10
|
-
CelValue::Bool(b) => JsonValue::Bool(*b),
|
|
11
|
-
|
|
12
|
-
CelValue::Int(i) => JsonValue::Number((*i).into()),
|
|
13
|
-
|
|
14
|
-
CelValue::UInt(u) => JsonValue::Number((*u).into()),
|
|
15
|
-
|
|
16
|
-
CelValue::Float(f) => {
|
|
17
|
-
// serde_json::Number doesn't support NaN or infinity
|
|
18
|
-
// Handle these edge cases appropriately
|
|
19
|
-
if f.is_finite() {
|
|
20
|
-
serde_json::Number::from_f64(*f)
|
|
21
|
-
.map(JsonValue::Number)
|
|
22
|
-
.unwrap_or(JsonValue::Null)
|
|
23
|
-
} else {
|
|
24
|
-
JsonValue::Null
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
CelValue::String(s) => JsonValue::String(s.to_string()),
|
|
29
|
-
|
|
30
|
-
CelValue::List(list) => {
|
|
31
|
-
let json_array: Vec<JsonValue> = list.iter().map(cel_value_to_json_value).collect();
|
|
32
|
-
JsonValue::Array(json_array)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
CelValue::Map(map) => {
|
|
36
|
-
let mut json_map = serde_json::Map::new();
|
|
37
|
-
for (key, val) in map.map.iter() {
|
|
38
|
-
// Convert Key to string
|
|
39
|
-
let key_string = match key {
|
|
40
|
-
Key::String(s) => s.to_string(),
|
|
41
|
-
Key::Int(i) => i.to_string(),
|
|
42
|
-
Key::Uint(u) => u.to_string(),
|
|
43
|
-
Key::Bool(b) => b.to_string(),
|
|
44
|
-
};
|
|
45
|
-
json_map.insert(key_string, cel_value_to_json_value(val));
|
|
46
|
-
}
|
|
47
|
-
JsonValue::Object(json_map)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Handle any other CEL value types by converting to string representation
|
|
51
|
-
_ => JsonValue::String(format!("{:?}", value)),
|
|
52
|
-
}
|
|
53
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|