Skip to main content

A CEL command-line query tool for JSON data

Project description

celq

Crates.io Documentation Playground Minimum rustc 1.90

celq is a command-line tool for evaluating Common Expression Language (CEL) expressions. It processes JSON input, performs computations, and outputs results. Think of it as if jq supported CEL.

Quick Start

celq reads JSON from the input and lets users process it with CEL:

echo '["apples", "bananas", "blueberry"]' | celq 'this.filter(s, s.contains("a"))'
# Outputs: ["apples","bananas"]

celq can also evaluate expressions with arguments, without reading from the input:

celq -n --arg='fruit:string=apple' 'fruit.contains("a")'
# Outputs: true

Popular configuration formats such as JSON5, YAML, TOML, and XML are supported. The closely related format NDJSON is also supported.

For detailed usage examples and recipes, see the manual.

Interactive Playground

Want to try celq without installing anything? Visit the celq-playground to try it in your browser!

Why?

There are implementations of CEL for Go, Java, C++, JavaScript, Python, C#, Rust, Ruby, and possibly more languages.

celq brings the same CEL syntax to the command-line. celq is not necessarily better than jq, but perhaps it makes it easier to reuse snippets of code across multiple places.

Moreover, the CEL specification is simpler than the jqlang specification. If you need something less powerful than jq or Python, then celq might be what you are looking for.

Check our comparison with other tools for more details.

Installation

Pre-built Binaries

We publish pre-built binaries for Linux, macOS, FreeBSD, and Windows in celq's GitHub Releases page. To install the current version for Linux or macOS, run:

curl --proto '=https' --tlsv1.2 -sSf https://get-celq.github.io/install.sh | bash

Notice that the installer tries not to be clever and doesn't modify $PATH or overwrite existing files. To specify a destination, use the --to flag:

curl --proto '=https' --tlsv1.2 -sSf https://get-celq.github.io/install.sh | \
    bash -s -- --to DESTINATION

See the installation guide for more details on the installer such as --force to replace existing binaries, --target to specify which binary to download, versioned URLs, GitHub tokens, attestations, and more.

Homebrew (macOS)

If you are a macOS Homebrew user, then you can install celq with:

brew install get-celq/tap/celq

Scoop (Windows)

If you are a Scoop user on Windows, you can install celq with:

scoop bucket add get-celq https://github.com/get-celq/scoop-bucket
scoop install get-celq/celq

Chocolatey (Windows)

If you are a Chocolatey user on Windows, you can install celq with:

choco install celq

WinGet (Windows)

If you are a WinGet user on Windows, you can install celq with:

winget install IvanIsCoding.celq

Cargo

Installing From Source

If you want to install from source, celq publishes to crates.io.

cargo install celq --locked

Installing With cargo-binstall

If you have cargo-binstall installed, you can install pre-built binaries directly:

cargo binstall celq

GitHub Actions

celq can be used in GitHub actions. For one-off commands, the get-celq/celq-action is the quickest way:

- name: Example Celq Action
  id: exampleID
  uses: get-celq/celq-action@main
  with:
    cmd: celq 'this.exampleID' < example.json

- name: Reuse a variable obtained in another step
  run: echo ${{ steps.exampleID.outputs.result }}

See the installation guide for more details on GitHub actions such as pinning the celq version and the Action itself.

If you are going to use celq in scripts or for multiple calls, we recommend using taiki-e/install-action:

- uses: taiki-e/install-action@v2
  with:
    tool: celq

Nix

celq is available for Nix. To run it as a Flake:

nix run github:IvanIsCoding/celq -- -n '"Hello World"'

By default, Nix fetches the stable version from crates.io. If you want to run the code from HEAD, use the dev derivation:

nix run github:IvanIsCoding/celq#dev -- -n '"Hello World"'

See the installation guide for other Nix setups.

FreeBSD

FreeBSD builds are tested with freebsd-vm and cross-compiled with Zig. Although celq is not yet in the ports tree, it does publish pre-built binaries:

VERSION=v0.5.0
RELEASE_URL=https://github.com/IvanIsCoding/celq/releases/download/${VERSION}
PLATFORM=x86_64 # or aarch64

fetch ${RELEASE_URL}/celq-freebsd-${PLATFORM}.tar.gz

tar xzf celq-freebsd-${PLATFORM}.tar.gz
su root -c 'install -m 755 celq /usr/local/bin/'

celq can also be installed from source following the Cargo section. We strive to always compile with the Rust version provided in the ports tree.

OpenBSD

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 section for installation instructions.

NetBSD

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 section for installation instructions.

NPM (Node.js/JavaScript)

celq is packaged for NPM. Node.js users can install celq in their project with:

npm install celq

This adds celq to package.json and makes it available for scripts. It is also possible to run single commands with npx:

npx celq -n '"Hello World"'

Python

celq is packaged for PyPI. Python users can install it with pip:

pip install celq

If you have uv installed, celq can be used as a tool:

uvx celq -n '"Hello World"'

Conda Forge

celq is available on conda-forge and can be installed with conda, mamba, micromamba, and pixi:

conda install -c conda-forge celq

If you have pixi, you can run celq in a temporary environment with:

pixi exec celq -n '"Hello World"'

Mise

celq can be used with mise. To install celq, use the Conda back-end:

mise use -g conda:celq

Alternatively, add this to mise.toml:

[tools]
"conda:celq" = "latest"

Limitations

Eager JSON Parsing

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.

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.

CEL Implementation Differences

celq uses cel-rust, a community-maintained Rust implementation of CEL, rather than the official Go implementation.

There may be edge cases or advanced features where behavior differs from the official implementation. If you find one, open an issue at the celq repository and we'll triage the issue before sending it to cel-rust.

List and Map Arguments

Currently, the --arg syntax only supports int, bool, float, and string. Support for other CEL types will be added in the future.

Malformed expressions

Currently, the error messages for CEL expressions that are invalid are cryptic. We will enhance them in future releases.

Non-Goals

REPL

While conceptually interesting, celq does not aim to be a CEL REPL. In the original author's view, that should live on a separate binary.

Full YAML Support

celq works with JSON. YAML is supported as a best-effort. If the ingested YAML can be translated to JSON, celq most likely works fine. Full YAML support is out-of-scope, as the specification has too many edge cases.

Acknowledgments

Special thanks to the maintainers of:

  • cel-rust for providing the CEL evaluation engine that powers celq
  • cel-python for publishing their CLI. celq has heavily drawn from their interface
  • jaq for giving an excellent blueprint on how to test a Rust CLI
  • gron for greppable JSON

Large Language Models Disclosure

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.

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.

License

This project is dual-licensed under the MIT License and Apache 2.0 licenses. See LICENSE-MIT and LICENSE-APACHE files for details.

The install.sh published with each GitHub release and its template at the root of the repository (template_install.sh) are licensed independently. Those files are under the CC0-1.0 license. They are the original work of Casey Rodarmor from just and have been adapted for celq.

Contributing

Contributions are welcome! See CONTRIBUTING.md for more details.

Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion in celq by you shall be dual-licensed under the MIT License and the Apache 2.0 license. Contributions to template_install.sh shall be dedicated to the public domain. Any additional terms or conditions shall not apply.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

celq-0.5.0.tar.gz (68.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

celq-0.5.0-py3-none-win_amd64.whl (2.0 MB view details)

Uploaded Python 3Windows x86-64

celq-0.5.0-py3-none-musllinux_1_2_x86_64.whl (2.0 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

celq-0.5.0-py3-none-musllinux_1_2_aarch64.whl (1.9 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

celq-0.5.0-py3-none-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

celq-0.5.0-py3-none-manylinux_2_28_aarch64.whl (1.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

celq-0.5.0-py3-none-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

celq-0.5.0-py3-none-macosx_10_12_x86_64.whl (2.1 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file celq-0.5.0.tar.gz.

File metadata

  • Download URL: celq-0.5.0.tar.gz
  • Upload date:
  • Size: 68.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celq-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ea23f55f738552e7e7e0d3023ba4bf296079cee8d246dab1db7e6b08787d2490
MD5 1d7f7277d8ecb5dfde6be3d74518c364
BLAKE2b-256 4365f46c7433a0706044a74c9392f368de8fb4d42ce24078e8714b88aaf4cb1f

See more details on using hashes here.

File details

Details for the file celq-0.5.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: celq-0.5.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celq-0.5.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 711b43b61f051c211ad8d237ad9e578efcb5e3f541f452eaf5095c69fcecebfd
MD5 8b83ef24695de81ff48c4d851e5e0180
BLAKE2b-256 0fcba39e2237897f4963fb42bf53ba807728ab4a12d7b1ffc418530ce2996208

See more details on using hashes here.

File details

Details for the file celq-0.5.0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: celq-0.5.0-py3-none-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: Python 3, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celq-0.5.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 037c807ac2df6516572bdfae6fc85d030d42d6c87ec9fdc0c16f687f2b1b4319
MD5 65556f24fef21fe35e10181931aed131
BLAKE2b-256 a4d4881705b67e2c0aebdca2d555b4bed60f3bb3445cbd694a7b5d7412e7af6a

See more details on using hashes here.

File details

Details for the file celq-0.5.0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

  • Download URL: celq-0.5.0-py3-none-musllinux_1_2_aarch64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3, musllinux: musl 1.2+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celq-0.5.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 dcdc5ffd5d3311a5cc3844b5cf1e243e0fac3891b4a6e908049a2ce6dc355595
MD5 0ae05ed747d30c9596b17a2022476b15
BLAKE2b-256 2fa1d5b7d21532f8b90245dbcea7fee3a905f93dae2b9bfb532e60a3294185df

See more details on using hashes here.

File details

Details for the file celq-0.5.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: celq-0.5.0-py3-none-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: Python 3, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celq-0.5.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6f5a48f3637a821930854ba7c70367db27d26d620704130d31ed4b0dff7670fa
MD5 d82d184f9db9b401995b1650dbdcb729
BLAKE2b-256 14b3d824dfa63707773078c12061d50db720852b1c06e745f60c5157b423b407

See more details on using hashes here.

File details

Details for the file celq-0.5.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

  • Download URL: celq-0.5.0-py3-none-manylinux_2_28_aarch64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3, manylinux: glibc 2.28+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celq-0.5.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7e8e767c79988c2a331de2e35c80b1f09f05a91200c083fa98ab22755d26e904
MD5 0b12a47ec5713d6b7f612a4829ff5779
BLAKE2b-256 ec8cd015418e5c3c278078cd950cf733e4ca68b68de04d920bdc1eac759769c3

See more details on using hashes here.

File details

Details for the file celq-0.5.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: celq-0.5.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celq-0.5.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a827a8d7ff52e3ac0825cf7b167f630093e798faf50f554c27eb12c6fb1e3a71
MD5 7278a4022eb246ac823791588e21dff9
BLAKE2b-256 45482194cf780a5051af3cf2143031c76c216e4c3d7a1d778ba378fe189c198e

See more details on using hashes here.

File details

Details for the file celq-0.5.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: celq-0.5.0-py3-none-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: Python 3, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celq-0.5.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c493fe5f8fc74c3b14313ad9cddecf1f0756d1f62c630d1196d99af01333ac29
MD5 b861f6024e821453441e1deed677c140
BLAKE2b-256 ffbad8c0c22727e28599c0fcfe4fe28290dae1dc769956025853f76fe217d7d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page