celq 0.3.1__tar.gz → 0.3.3__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.
Files changed (29) hide show
  1. {celq-0.3.1 → celq-0.3.3}/CHANGELOG.md +18 -0
  2. {celq-0.3.1 → celq-0.3.3}/Cargo.lock +24 -1
  3. {celq-0.3.1 → celq-0.3.3}/Cargo.toml +5 -3
  4. {celq-0.3.1 → celq-0.3.3}/PKG-INFO +52 -7
  5. {celq-0.3.1 → celq-0.3.3}/README.md +51 -6
  6. {celq-0.3.1 → celq-0.3.3}/docs/installation_guide.md +50 -5
  7. {celq-0.3.1 → celq-0.3.3}/docs/manual.md +58 -3
  8. {celq-0.3.1 → celq-0.3.3}/pypi/README.md +51 -6
  9. {celq-0.3.1 → celq-0.3.3}/src/cli.rs +7 -0
  10. {celq-0.3.1 → celq-0.3.3}/src/json2cel.rs +17 -0
  11. {celq-0.3.1 → celq-0.3.3}/tests/golden.rs +103 -0
  12. {celq-0.3.1 → celq-0.3.3}/LICENSE-APACHE +0 -0
  13. {celq-0.3.1 → celq-0.3.3}/LICENSE-MIT +0 -0
  14. {celq-0.3.1 → celq-0.3.3}/docs/comparison_with_other_tools.md +0 -0
  15. {celq-0.3.1 → celq-0.3.3}/pypi/LICENSE-APACHE +0 -0
  16. {celq-0.3.1 → celq-0.3.3}/pypi/LICENSE-MIT +0 -0
  17. {celq-0.3.1 → celq-0.3.3}/pyproject.toml +0 -0
  18. {celq-0.3.1 → celq-0.3.3}/src/args2cel.rs +0 -0
  19. {celq-0.3.1 → celq-0.3.3}/src/args2cel_test.rs +0 -0
  20. {celq-0.3.1 → celq-0.3.3}/src/documentation.rs +0 -0
  21. {celq-0.3.1 → celq-0.3.3}/src/gron.rs +0 -0
  22. {celq-0.3.1 → celq-0.3.3}/src/gron_test.rs +0 -0
  23. {celq-0.3.1 → celq-0.3.3}/src/input_handler.rs +0 -0
  24. {celq-0.3.1 → celq-0.3.3}/src/input_handler_test.rs +0 -0
  25. {celq-0.3.1 → celq-0.3.3}/src/json2cel_test.rs +0 -0
  26. {celq-0.3.1 → celq-0.3.3}/src/main.rs +0 -0
  27. {celq-0.3.1 → celq-0.3.3}/src/slice_extension.rs +0 -0
  28. {celq-0.3.1 → celq-0.3.3}/src/ungron.rs +0 -0
  29. {celq-0.3.1 → celq-0.3.3}/src/ungron_test.rs +0 -0
@@ -1,7 +1,25 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ [v0.3.3](https://github.com/IvanIsCoding/celq/releases/tag/v0.3.1) - 2026-02-05
5
+ ------------------------------------------------------------------------
6
+
7
+
8
+ ### Added
9
+
10
+ * Added XML support via the `--from-xml` flag.
11
+
12
+ [v0.3.2](https://github.com/IvanIsCoding/celq/releases/tag/v0.3.2) - 2026-01-31
13
+ ------------------------------------------------------------------------
14
+
15
+
16
+ ### Miscellaneous
17
+
18
+ * Downgraded the MSRV to Rust 1.90
19
+
4
20
  [v0.3.1](https://github.com/IvanIsCoding/celq/releases/tag/v0.3.1) - 2026-01-27
21
+ ------------------------------------------------------------------------
22
+
5
23
 
6
24
  ### Added
7
25
 
@@ -201,7 +201,7 @@ dependencies = [
201
201
 
202
202
  [[package]]
203
203
  name = "celq"
204
- version = "0.3.1"
204
+ version = "0.3.3"
205
205
  dependencies = [
206
206
  "anyhow",
207
207
  "cel",
@@ -216,6 +216,7 @@ dependencies = [
216
216
  "serde_json",
217
217
  "tempfile",
218
218
  "toml",
219
+ "xml2json-rs",
219
220
  ]
220
221
 
221
222
  [[package]]
@@ -583,6 +584,15 @@ dependencies = [
583
584
  "unicode-ident",
584
585
  ]
585
586
 
587
+ [[package]]
588
+ name = "quick-xml"
589
+ version = "0.23.1"
590
+ source = "registry+https://github.com/rust-lang/crates.io-index"
591
+ checksum = "11bafc859c6815fbaffbbbf4229ecb767ac913fecb27f9ad4343662e9ef099ea"
592
+ dependencies = [
593
+ "memchr",
594
+ ]
595
+
586
596
  [[package]]
587
597
  name = "quote"
588
598
  version = "1.0.42"
@@ -1143,6 +1153,19 @@ version = "0.46.0"
1143
1153
  source = "registry+https://github.com/rust-lang/crates.io-index"
1144
1154
  checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
1145
1155
 
1156
+ [[package]]
1157
+ name = "xml2json-rs"
1158
+ version = "1.0.1"
1159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1160
+ checksum = "c6ba4fb1256176d2eb02e25065efade8e43215a4d0743cb823991aea314077ea"
1161
+ dependencies = [
1162
+ "lazy_static",
1163
+ "quick-xml",
1164
+ "regex",
1165
+ "serde",
1166
+ "serde_json",
1167
+ ]
1168
+
1146
1169
  [[package]]
1147
1170
  name = "zerocopy"
1148
1171
  version = "0.8.33"
@@ -1,9 +1,9 @@
1
1
  [package]
2
2
  name = "celq"
3
3
  description = "A CEL command-line query tool for JSON data"
4
- version = "0.3.1"
4
+ version = "0.3.3"
5
5
  edition = "2024"
6
- rust-version = "1.91"
6
+ rust-version = "1.90"
7
7
  authors = ["Ivan Carvalho <ivancarvalho@gatech.edu>"]
8
8
  repository = "https://github.com/IvanIsCoding/celq"
9
9
  license = "MIT OR Apache-2.0"
@@ -34,9 +34,10 @@ name = "celq"
34
34
  path = "src/documentation.rs"
35
35
 
36
36
  [features]
37
- default = ["mimalloc", "from-toml", "from-yaml", "greppable"]
37
+ default = ["mimalloc", "from-toml", "from-yaml", "greppable", "from-xml"]
38
38
  from-toml = ["dep:toml"]
39
39
  from-yaml = ["dep:serde-saphyr"]
40
+ from-xml = ["dep:xml2json-rs"]
40
41
  greppable = ["dep:ressa", "dep:resast"]
41
42
 
42
43
  [dependencies]
@@ -52,6 +53,7 @@ toml = { version = "=0.9.8", default-features = false, features = ["parse", "ser
52
53
  serde-saphyr = { version = "=0.0.16", default-features = false, optional = true }
53
54
  ressa = { version = "=0.8.2", optional = true}
54
55
  resast = { version = "=0.5.0", optional = true }
56
+ xml2json-rs = {version = "=1.0.1", optional = true }
55
57
 
56
58
  [dev-dependencies]
57
59
  tempfile = "3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: celq
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Classifier: Intended Audience :: Developers
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: Implementation :: CPython
@@ -20,7 +20,7 @@ Project-URL: issues, https://github.com/IvanIsCoding/celq/issues
20
20
  Project-URL: source, https://github.com/IvanIsCoding/celq
21
21
 
22
22
  # celq
23
- [![Crates.io](https://img.shields.io/crates/v/celq.svg)](https://crates.io/crates/celq) [![Documentation](https://docs.rs/celq/badge.svg)](https://docs.rs/celq) [![Playground](https://img.shields.io/badge/playground-live-brightgreen)](https://celq-playground.github.io/) [![Minimum rustc 1.91](https://img.shields.io/badge/rustc-1.91+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
23
+ [![Crates.io](https://img.shields.io/crates/v/celq.svg)](https://crates.io/crates/celq) [![Documentation](https://docs.rs/celq/badge.svg)](https://docs.rs/celq) [![Playground](https://img.shields.io/badge/playground-live-brightgreen)](https://celq-playground.github.io/) [![Minimum rustc 1.90](https://img.shields.io/badge/rustc-1.90+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
24
24
 
25
25
  **celq** is a command-line tool for evaluating [Common Expression Language (CEL)](https://cel.dev/) expressions. It processes JSON input, performs computations, and outputs results. Think of it as if [jq](https://jqlang.org/) supported CEL.
26
26
 
@@ -40,7 +40,7 @@ celq -n --arg='fruit:string=apple' 'fruit.contains("a")'
40
40
  # Outputs: true
41
41
  ```
42
42
 
43
- Popular configuration formats such as JSON5, YAML, and TOML are supported. The closely related format NDJSON is also supported.
43
+ Popular configuration formats such as JSON5, YAML, TOML, and XML are supported. The closely related format NDJSON is also supported.
44
44
 
45
45
  For detailed usage examples and recipes, see the [manual](https://docs.rs/celq/latest/celq/).
46
46
 
@@ -84,6 +84,15 @@ If you are a [macOS Homebrew](https://brew.sh/) user, then you can install celq
84
84
  brew install get-celq/tap/celq
85
85
  ```
86
86
 
87
+ ### Scoop (Windows)
88
+
89
+ If you are a [Scoop](https://scoop.sh/) user on Windows, you can install `celq` with:
90
+
91
+ ```bash
92
+ scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
93
+ scoop install get-celq/celq
94
+ ```
95
+
87
96
  ### Chocolatey (Windows)
88
97
 
89
98
  If you are a [Chocolatey](https://community.chocolatey.org/) user on Windows, you can install `celq` with:
@@ -92,13 +101,12 @@ If you are a [Chocolatey](https://community.chocolatey.org/) user on Windows, yo
92
101
  choco install celq
93
102
  ```
94
103
 
95
- ### Scoop (Windows)
104
+ ### WinGet (Windows)
96
105
 
97
- If you are a [Scoop](https://scoop.sh/) user on Windows, you can install `celq` with:
106
+ If you are a [WinGet](https://learn.microsoft.com/windows/package-manager/winget/) user on Windows, you can install `celq` with:
98
107
 
99
108
  ```bash
100
- scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
101
- scoop install get-celq/celq
109
+ winget install IvanIsCoding.celq
102
110
  ```
103
111
 
104
112
  ### Cargo
@@ -177,6 +185,14 @@ su root -c 'install -m 755 celq /usr/local/bin/'
177
185
 
178
186
  `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
187
 
188
+ ### OpenBSD
189
+
190
+ OpenBSD builds are tested in CI using the latest stable release. `celq` strives to always compile with the Rust version provided in the ports tree. Refer to the [Cargo](#cargo) section for installation instructions.
191
+
192
+ ### NetBSD
193
+
194
+ NetBSD builds are tested in CI against the latest stable release. `celq` aims to remain compatible with the Rust version provided by the NetBSD pkgsrc quarterly branch. See the [Cargo](#cargo) section for installation instructions.
195
+
180
196
  ### NPM (Node.js/JavaScript)
181
197
 
182
198
  `celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
@@ -204,6 +220,35 @@ If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used
204
220
  uvx celq -n '"Hello World"'
205
221
  ```
206
222
 
223
+ ### Conda Forge
224
+
225
+ celq is available on [conda-forge](https://anaconda.org/channels/conda-forge/packages/celq/overview) and can be installed with `conda`, `mamba`, `micromamba`, and `pixi`:
226
+
227
+ ```bash
228
+ conda install -c conda-forge celq
229
+ ```
230
+
231
+ If you have [pixi](https://pixi.prefix.dev/latest/), you can run celq in a temporary environment with:
232
+
233
+ ```bash
234
+ pixi exec celq -n '"Hello World"'
235
+ ```
236
+
237
+ ### Mise
238
+
239
+ celq can be used with [mise](https://mise.jdx.dev/). To install celq, use the Conda back-end:
240
+
241
+ ```bash
242
+ mise use -g conda:celq
243
+ ```
244
+
245
+ Alternatively, add this to `mise.toml`:
246
+
247
+ ```toml
248
+ [tools]
249
+ "conda:celq" = "latest"
250
+ ```
251
+
207
252
  ## Limitations
208
253
 
209
254
  ### Eager JSON Parsing
@@ -1,5 +1,5 @@
1
1
  # celq
2
- [![Crates.io](https://img.shields.io/crates/v/celq.svg)](https://crates.io/crates/celq) [![Documentation](https://docs.rs/celq/badge.svg)](https://docs.rs/celq) [![Playground](https://img.shields.io/badge/playground-live-brightgreen)](https://celq-playground.github.io/) [![Minimum rustc 1.91](https://img.shields.io/badge/rustc-1.91+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
2
+ [![Crates.io](https://img.shields.io/crates/v/celq.svg)](https://crates.io/crates/celq) [![Documentation](https://docs.rs/celq/badge.svg)](https://docs.rs/celq) [![Playground](https://img.shields.io/badge/playground-live-brightgreen)](https://celq-playground.github.io/) [![Minimum rustc 1.90](https://img.shields.io/badge/rustc-1.90+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
3
3
 
4
4
  **celq** is a command-line tool for evaluating [Common Expression Language (CEL)](https://cel.dev/) expressions. It processes JSON input, performs computations, and outputs results. Think of it as if [jq](https://jqlang.org/) supported CEL.
5
5
 
@@ -19,7 +19,7 @@ celq -n --arg='fruit:string=apple' 'fruit.contains("a")'
19
19
  # Outputs: true
20
20
  ```
21
21
 
22
- Popular configuration formats such as JSON5, YAML, and TOML are supported. The closely related format NDJSON is also supported.
22
+ Popular configuration formats such as JSON5, YAML, TOML, and XML are supported. The closely related format NDJSON is also supported.
23
23
 
24
24
  For detailed usage examples and recipes, see the [manual](https://docs.rs/celq/latest/celq/).
25
25
 
@@ -63,6 +63,15 @@ If you are a [macOS Homebrew](https://brew.sh/) user, then you can install celq
63
63
  brew install get-celq/tap/celq
64
64
  ```
65
65
 
66
+ ### Scoop (Windows)
67
+
68
+ If you are a [Scoop](https://scoop.sh/) user on Windows, you can install `celq` with:
69
+
70
+ ```bash
71
+ scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
72
+ scoop install get-celq/celq
73
+ ```
74
+
66
75
  ### Chocolatey (Windows)
67
76
 
68
77
  If you are a [Chocolatey](https://community.chocolatey.org/) user on Windows, you can install `celq` with:
@@ -71,13 +80,12 @@ If you are a [Chocolatey](https://community.chocolatey.org/) user on Windows, yo
71
80
  choco install celq
72
81
  ```
73
82
 
74
- ### Scoop (Windows)
83
+ ### WinGet (Windows)
75
84
 
76
- If you are a [Scoop](https://scoop.sh/) user on Windows, you can install `celq` with:
85
+ If you are a [WinGet](https://learn.microsoft.com/windows/package-manager/winget/) user on Windows, you can install `celq` with:
77
86
 
78
87
  ```bash
79
- scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
80
- scoop install get-celq/celq
88
+ winget install IvanIsCoding.celq
81
89
  ```
82
90
 
83
91
  ### Cargo
@@ -156,6 +164,14 @@ su root -c 'install -m 755 celq /usr/local/bin/'
156
164
 
157
165
  `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.
158
166
 
167
+ ### OpenBSD
168
+
169
+ OpenBSD builds are tested in CI using the latest stable release. `celq` strives to always compile with the Rust version provided in the ports tree. Refer to the [Cargo](#cargo) section for installation instructions.
170
+
171
+ ### NetBSD
172
+
173
+ NetBSD builds are tested in CI against the latest stable release. `celq` aims to remain compatible with the Rust version provided by the NetBSD pkgsrc quarterly branch. See the [Cargo](#cargo) section for installation instructions.
174
+
159
175
  ### NPM (Node.js/JavaScript)
160
176
 
161
177
  `celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
@@ -183,6 +199,35 @@ If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used
183
199
  uvx celq -n '"Hello World"'
184
200
  ```
185
201
 
202
+ ### Conda Forge
203
+
204
+ celq is available on [conda-forge](https://anaconda.org/channels/conda-forge/packages/celq/overview) and can be installed with `conda`, `mamba`, `micromamba`, and `pixi`:
205
+
206
+ ```bash
207
+ conda install -c conda-forge celq
208
+ ```
209
+
210
+ If you have [pixi](https://pixi.prefix.dev/latest/), you can run celq in a temporary environment with:
211
+
212
+ ```bash
213
+ pixi exec celq -n '"Hello World"'
214
+ ```
215
+
216
+ ### Mise
217
+
218
+ celq can be used with [mise](https://mise.jdx.dev/). To install celq, use the Conda back-end:
219
+
220
+ ```bash
221
+ mise use -g conda:celq
222
+ ```
223
+
224
+ Alternatively, add this to `mise.toml`:
225
+
226
+ ```toml
227
+ [tools]
228
+ "conda:celq" = "latest"
229
+ ```
230
+
186
231
  ## Limitations
187
232
 
188
233
  ### Eager JSON Parsing
@@ -49,7 +49,16 @@ If you are a [macOS Homebrew](https://brew.sh/) user, then you can install celq
49
49
  brew install get-celq/tap/celq
50
50
  ```
51
51
 
52
- The formula also works for [Linuxbrew](https://docs.brew.sh/Homebrew-on-Linux), but it will install from source instead of using pre-built binaries.
52
+ The formula also works for [Linuxbrew](https://docs.brew.sh/Homebrew-on-Linux).
53
+
54
+ ### Scoop (Windows)
55
+
56
+ If you are a [Scoop](https://scoop.sh/) user on Windows, you can install `celq` with:
57
+
58
+ ```bash
59
+ scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
60
+ scoop install get-celq/celq
61
+ ```
53
62
 
54
63
  ### Chocolatey (Windows)
55
64
 
@@ -59,13 +68,12 @@ If you are a [Chocolatey](https://community.chocolatey.org/) user on Windows, yo
59
68
  choco install celq
60
69
  ```
61
70
 
62
- ### Scoop (Windows)
71
+ ### WinGet (Windows)
63
72
 
64
- If you are a [Scoop](https://scoop.sh/) user on Windows, you can install `celq` with:
73
+ If you are a [WinGet](https://learn.microsoft.com/windows/package-manager/winget/) user on Windows, you can install `celq` with:
65
74
 
66
75
  ```bash
67
- scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
68
- scoop install get-celq/celq
76
+ winget install IvanIsCoding.celq
69
77
  ```
70
78
 
71
79
  ### Cargo
@@ -166,6 +174,14 @@ su root -c 'install -m 755 celq /usr/local/bin/'
166
174
 
167
175
  `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.
168
176
 
177
+ ### OpenBSD
178
+
179
+ OpenBSD builds are tested in CI using the latest stable release. `celq` strives to always compile with the Rust version provided in the ports tree. Refer to the [Cargo](#cargo) section for installation instructions.
180
+
181
+ ### NetBSD
182
+
183
+ NetBSD builds are tested in CI against the latest stable release. `celq` aims to remain compatible with the Rust version provided by the NetBSD pkgsrc quarterly branch. See the [Cargo](#cargo) section for installation instructions.
184
+
169
185
  ### NPM (Node.js/JavaScript)
170
186
 
171
187
  `celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
@@ -193,6 +209,35 @@ If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used
193
209
  uvx celq -n '"Hello World"'
194
210
  ```
195
211
 
212
+ ### Conda Forge
213
+
214
+ celq is available on [conda-forge](https://anaconda.org/channels/conda-forge/packages/celq/overview) and can be installed with `conda`, `mamba`, `micromamba`, and `pixi`:
215
+
216
+ ```bash
217
+ conda install -c conda-forge celq
218
+ ```
219
+
220
+ If you have [pixi](https://pixi.prefix.dev/latest/), you can run celq in a temporary environment with:
221
+
222
+ ```bash
223
+ pixi exec celq -n '"Hello World"'
224
+ ```
225
+
226
+ ### Mise
227
+
228
+ celq can be used with [mise](https://mise.jdx.dev/). To install celq, use the Conda back-end:
229
+
230
+ ```bash
231
+ mise use -g conda:celq
232
+ ```
233
+
234
+ Alternatively, add this to `mise.toml`:
235
+
236
+ ```toml
237
+ [tools]
238
+ "conda:celq" = "latest"
239
+ ```
240
+
196
241
  ## Integrity and Authenticity
197
242
 
198
243
  `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.
@@ -39,10 +39,10 @@ See the [installation guide](`crate::installation_guide`) for installation instr
39
39
  ```none
40
40
  A CEL command-line query tool for JSON data
41
41
 
42
- Usage: celq [OPTIONS] <expr|--from-file <FILE>>
42
+ Usage: celq [OPTIONS] [expr]
43
43
 
44
44
  Arguments:
45
- [expr] CEL expression to evaluate
45
+ [expr] CEL expression to evaluate [default: this]
46
46
 
47
47
  Options:
48
48
  -a, --arg <name:type=value> Define argument variables, types, and values. Format: name:type=value. Supported types: int, uint, float, bool, string
@@ -53,6 +53,7 @@ Options:
53
53
  --from-json5 Parse input as JSON5 instead of JSON
54
54
  --from-toml Parse input as TOML instead of JSON
55
55
  --from-yaml Parse input as YAML instead of JSON
56
+ --from-xml Parse input as XML instead of JSON
56
57
  --from-gron Parse input as gron (greppable output) instead of JSON
57
58
  -j, --jobs <N> Parallelism level for NDJSON inputs (number of threads, -1 for all available) [default: 1]
58
59
  -R, --root-var <ROOT_VAR> Variable name for the root JSON input [default: this]
@@ -144,8 +145,8 @@ This file contains the simplified response from the Yahoo Finance Unofficial JSO
144
145
  * [this keyword](#this-keyword)
145
146
  * [Writing Files](#writing-files)
146
147
  * [Output JSON](#output-json)
147
- * [Slicing lists](#slicing-lists)
148
148
  * [Reading CEL from a file](#reading-cel-from-a-file)
149
+ * [Slicing lists](#slicing-lists)
149
150
  * [Dealing with NDJSON](#dealing-with-ndjson)
150
151
  * [Slurping](#slurping)
151
152
  * [Logical Calculator](#logical-calculator)
@@ -156,6 +157,7 @@ This file contains the simplified response from the Yahoo Finance Unofficial JSO
156
157
  * [TOML Support](#toml-support)
157
158
  * [YAML Support](#yaml-support)
158
159
  * [YAML with multiple documents](#yaml-with-multiple-documents)
160
+ * [XML Support](#xml-support)
159
161
  * [Pretty Printing](#pretty-printing)
160
162
  * [Raw Output](#raw-output)
161
163
  * [Grep friendly output](#grep-friendly-output)
@@ -444,6 +446,59 @@ The document gets parsed as a list of documents. To access the `tags` field of t
444
446
  celq --from-yaml 'this[1].tags' < multi.yaml
445
447
  ```
446
448
 
449
+ ### XML Support
450
+
451
+ `celq` supports XML via the `--froml-xml` flag. Take `example.xml`:
452
+
453
+ <details>
454
+ <summary>example.xml</summary>
455
+
456
+ ```xml
457
+ <?xml version="1.0"?>
458
+ <items>
459
+ <item id="1">
460
+ <name>apple</name>
461
+ <price>1.25</price>
462
+ </item>
463
+ <item id="2">
464
+ <name>banana</name>
465
+ <price>0.75</price>
466
+ </item>
467
+ </items>
468
+ ```
469
+ </details>
470
+
471
+ Running `celq --from-xml -S < example.xml` converts it to the following:
472
+
473
+ <details>
474
+ <summary>example_xml.json</summary>
475
+
476
+ ```json
477
+ {
478
+ "items": {
479
+ "item": [
480
+ {
481
+ "$": {
482
+ "id": "1"
483
+ },
484
+ "name": "apple",
485
+ "price": "1.25"
486
+ },
487
+ {
488
+ "$": {
489
+ "id": "2"
490
+ },
491
+ "name": "banana",
492
+ "price": "0.75"
493
+ }
494
+ ]
495
+ }
496
+ }
497
+ ```
498
+ </details>
499
+
500
+ `celq`'s XML parser does not try to convert types and puts attributes in the `$` field.
501
+
447
502
  ### Pretty Printing
448
503
 
449
504
  `celq` by default uses a compact output. This is a contrast to `jq` where the compact output is an opt-in with the `-c` flag.
@@ -1,5 +1,5 @@
1
1
  # celq
2
- [![Crates.io](https://img.shields.io/crates/v/celq.svg)](https://crates.io/crates/celq) [![Documentation](https://docs.rs/celq/badge.svg)](https://docs.rs/celq) [![Playground](https://img.shields.io/badge/playground-live-brightgreen)](https://celq-playground.github.io/) [![Minimum rustc 1.91](https://img.shields.io/badge/rustc-1.91+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
2
+ [![Crates.io](https://img.shields.io/crates/v/celq.svg)](https://crates.io/crates/celq) [![Documentation](https://docs.rs/celq/badge.svg)](https://docs.rs/celq) [![Playground](https://img.shields.io/badge/playground-live-brightgreen)](https://celq-playground.github.io/) [![Minimum rustc 1.90](https://img.shields.io/badge/rustc-1.90+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
3
3
 
4
4
  **celq** is a command-line tool for evaluating [Common Expression Language (CEL)](https://cel.dev/) expressions. It processes JSON input, performs computations, and outputs results. Think of it as if [jq](https://jqlang.org/) supported CEL.
5
5
 
@@ -19,7 +19,7 @@ celq -n --arg='fruit:string=apple' 'fruit.contains("a")'
19
19
  # Outputs: true
20
20
  ```
21
21
 
22
- Popular configuration formats such as JSON5, YAML, and TOML are supported. The closely related format NDJSON is also supported.
22
+ Popular configuration formats such as JSON5, YAML, TOML, and XML are supported. The closely related format NDJSON is also supported.
23
23
 
24
24
  For detailed usage examples and recipes, see the [manual](https://docs.rs/celq/latest/celq/).
25
25
 
@@ -63,6 +63,15 @@ If you are a [macOS Homebrew](https://brew.sh/) user, then you can install celq
63
63
  brew install get-celq/tap/celq
64
64
  ```
65
65
 
66
+ ### Scoop (Windows)
67
+
68
+ If you are a [Scoop](https://scoop.sh/) user on Windows, you can install `celq` with:
69
+
70
+ ```bash
71
+ scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
72
+ scoop install get-celq/celq
73
+ ```
74
+
66
75
  ### Chocolatey (Windows)
67
76
 
68
77
  If you are a [Chocolatey](https://community.chocolatey.org/) user on Windows, you can install `celq` with:
@@ -71,13 +80,12 @@ If you are a [Chocolatey](https://community.chocolatey.org/) user on Windows, yo
71
80
  choco install celq
72
81
  ```
73
82
 
74
- ### Scoop (Windows)
83
+ ### WinGet (Windows)
75
84
 
76
- If you are a [Scoop](https://scoop.sh/) user on Windows, you can install `celq` with:
85
+ If you are a [WinGet](https://learn.microsoft.com/windows/package-manager/winget/) user on Windows, you can install `celq` with:
77
86
 
78
87
  ```bash
79
- scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
80
- scoop install get-celq/celq
88
+ winget install IvanIsCoding.celq
81
89
  ```
82
90
 
83
91
  ### Cargo
@@ -156,6 +164,14 @@ su root -c 'install -m 755 celq /usr/local/bin/'
156
164
 
157
165
  `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.
158
166
 
167
+ ### OpenBSD
168
+
169
+ OpenBSD builds are tested in CI using the latest stable release. `celq` strives to always compile with the Rust version provided in the ports tree. Refer to the [Cargo](#cargo) section for installation instructions.
170
+
171
+ ### NetBSD
172
+
173
+ NetBSD builds are tested in CI against the latest stable release. `celq` aims to remain compatible with the Rust version provided by the NetBSD pkgsrc quarterly branch. See the [Cargo](#cargo) section for installation instructions.
174
+
159
175
  ### NPM (Node.js/JavaScript)
160
176
 
161
177
  `celq` is packaged for [NPM](https://www.npmjs.com/package/celq). Node.js users can install celq in their project with:
@@ -183,6 +199,35 @@ If you have [uv](https://github.com/astral-sh/uv) installed, `celq` can be used
183
199
  uvx celq -n '"Hello World"'
184
200
  ```
185
201
 
202
+ ### Conda Forge
203
+
204
+ celq is available on [conda-forge](https://anaconda.org/channels/conda-forge/packages/celq/overview) and can be installed with `conda`, `mamba`, `micromamba`, and `pixi`:
205
+
206
+ ```bash
207
+ conda install -c conda-forge celq
208
+ ```
209
+
210
+ If you have [pixi](https://pixi.prefix.dev/latest/), you can run celq in a temporary environment with:
211
+
212
+ ```bash
213
+ pixi exec celq -n '"Hello World"'
214
+ ```
215
+
216
+ ### Mise
217
+
218
+ celq can be used with [mise](https://mise.jdx.dev/). To install celq, use the Conda back-end:
219
+
220
+ ```bash
221
+ mise use -g conda:celq
222
+ ```
223
+
224
+ Alternatively, add this to `mise.toml`:
225
+
226
+ ```toml
227
+ [tools]
228
+ "conda:celq" = "latest"
229
+ ```
230
+
186
231
  ## Limitations
187
232
 
188
233
  ### Eager JSON Parsing
@@ -24,6 +24,7 @@ pub enum InputFormat {
24
24
  Json5,
25
25
  Toml,
26
26
  Yaml,
27
+ Xml,
27
28
  Gron,
28
29
  }
29
30
 
@@ -129,6 +130,10 @@ pub struct Cli {
129
130
  #[arg(long = "from-yaml")]
130
131
  pub from_yaml: bool,
131
132
 
133
+ /// Parse input as XML instead of JSON
134
+ #[arg(long = "from-xml")]
135
+ pub from_xml: bool,
136
+
132
137
  /// Parse input as gron (greppable output) instead of JSON
133
138
  #[arg(long = "from-gron")]
134
139
  pub from_gron: bool,
@@ -184,6 +189,8 @@ impl Cli {
184
189
  InputFormat::Yaml
185
190
  } else if self.from_toml {
186
191
  InputFormat::Toml
192
+ } else if self.from_xml {
193
+ InputFormat::Xml
187
194
  } else if self.from_json5 {
188
195
  InputFormat::Json5
189
196
  } else if self.slurp {
@@ -62,6 +62,23 @@ pub fn json_to_cel_variables(
62
62
  ));
63
63
  }
64
64
  }
65
+ InputFormat::Xml => {
66
+ #[cfg(feature = "from-xml")]
67
+ {
68
+ xml2json_rs::JsonConfig::new()
69
+ .explicit_array(false)
70
+ .finalize()
71
+ .build_from_xml(json_str)
72
+ .map_err(serde_json::Error::custom)?
73
+ }
74
+
75
+ #[cfg(not(feature = "from-xml"))]
76
+ {
77
+ return Err(serde_json::Error::custom(
78
+ "Binary was compiled without XML support",
79
+ ));
80
+ }
81
+ }
65
82
  InputFormat::Gron => {
66
83
  #[cfg(feature = "greppable")]
67
84
  {
@@ -951,3 +951,106 @@ fn test_slice_fails_without_extensions() -> io::Result<()> {
951
951
 
952
952
  Ok(())
953
953
  }
954
+
955
+ // XML tests
956
+
957
+ // XML with nested elements
958
+ #[cfg(feature = "from-xml")]
959
+ test!(
960
+ xml_nested_elements,
961
+ &[
962
+ "--from-xml",
963
+ "this.database.host + ':' + string(this.database.port)"
964
+ ],
965
+ r#"<database>
966
+ <host>localhost</host>
967
+ <port>5432</port>
968
+ </database>"#,
969
+ "\"localhost:5432\""
970
+ );
971
+
972
+ #[cfg(feature = "from-xml")]
973
+ test!(
974
+ xml_array_of_elements,
975
+ &["--from-xml", "this.servers.server.map(s, s.ip)"],
976
+ r#"<servers>
977
+ <server>
978
+ <ip>192.168.1.1</ip>
979
+ <name>alpha</name>
980
+ </server>
981
+ <server>
982
+ <ip>192.168.1.2</ip>
983
+ <name>beta</name>
984
+ </server>
985
+ </servers>"#,
986
+ "[\"192.168.1.1\",\"192.168.1.2\"]"
987
+ );
988
+
989
+ #[cfg(feature = "from-xml")]
990
+ test!(
991
+ xml_with_attributes,
992
+ &[
993
+ "--from-xml",
994
+ "this.user.name + ' <' + this.user.email + '>'"
995
+ ],
996
+ r#"<user>
997
+ <name>Alice</name>
998
+ <email>alice@example.com</email>
999
+ </user>"#,
1000
+ "\"Alice <alice@example.com>\""
1001
+ );
1002
+
1003
+ #[cfg(feature = "from-xml")]
1004
+ test!(
1005
+ xml_simple_structure,
1006
+ &["--from-xml", "int(this.point.x) + int(this.point.y)"],
1007
+ r#"<point>
1008
+ <x>10</x>
1009
+ <y>20</y>
1010
+ </point>"#,
1011
+ "30"
1012
+ );
1013
+
1014
+ #[cfg(feature = "from-xml")]
1015
+ test!(
1016
+ xml_text_content,
1017
+ &["--from-xml", "this.message"],
1018
+ r#"<message>Hello, World!</message>"#,
1019
+ r#""Hello, World!""#
1020
+ );
1021
+
1022
+ #[cfg(feature = "from-xml")]
1023
+ test!(
1024
+ xml_mixed_content,
1025
+ &[
1026
+ "--from-xml",
1027
+ "this.person.name + ' is ' + string(this.person.age)"
1028
+ ],
1029
+ r#"<person>
1030
+ <name>Bob</name>
1031
+ <age>25</age>
1032
+ </person>"#,
1033
+ "\"Bob is 25\""
1034
+ );
1035
+
1036
+ #[cfg(feature = "from-xml")]
1037
+ test!(
1038
+ xml_to_pretty_sorted_json,
1039
+ &["--from-xml", "--sort-keys", "--pretty-print", "this"],
1040
+ r#"<root>
1041
+ <person>
1042
+ <name>Alice</name>
1043
+ <age>30</age>
1044
+ </person>
1045
+ <id>1</id>
1046
+ </root>"#,
1047
+ r#"{
1048
+ "root": {
1049
+ "id": "1",
1050
+ "person": {
1051
+ "age": "30",
1052
+ "name": "Alice"
1053
+ }
1054
+ }
1055
+ }"#
1056
+ );
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