Crates.io | gelx_cli |
lib.rs | gelx_cli |
version | 0.8.5 |
created_at | 2025-05-19 16:28:23.08045+00 |
updated_at | 2025-08-02 07:58:34.211382+00 |
description | Generate fully typed rust code from your gel schema and inline queries. |
homepage | https://geldata.com |
repository | https://github.com/ifiokjr/gelx |
max_upload_size | |
id | 1679997 |
size | 110,818 |
gelx_cli
A command-line interface for
gelx
to generate fully typed Rust code from your Gel schema and query files.
The gelx_cli
is distributed as part of the gelx
workspace. To use it, you can build the workspace and then run the gelx
binary from the target directory, or install it using cargo
:
cargo install gelx_cli
Alternatively, you can install it directly from the github repo:
cargo install --git https://github.com/ifiokjr/gelx.git gelx_cli
The above two commands are the typical ways to install gelx_cli
. However, if you use gel
in multiple projects with multiple versions of the gelx
crate, you should install it locally per project using cargo-run-bin
.
First install cargo-run-bin
:
cargo install cargo-run-bin
Inside a single crate project add the following to the Cargo.toml
file:
[package.metadata.bin]
gelx_cli = { version = "0.8.2", bins = ["gelx"] }
Inside a workspace add the following to the Cargo.toml
file:
[workspace.metadata.bin]
gelx_cli = { version = "0.8.2", bins = ["gelx"] }
Then run the following command to access gelx:
cargo bin gelx
Ensure your Gel instance is running and accessible, as the CLI needs to connect to it to introspect the schema and query types.
Run gelx help
to see the available commands and options.
Generate fully typed rust code from your gel schema and inline queries.
Usage: gelx [OPTIONS] <COMMAND>
Commands:
generate Generates Rust code from the crate in the current directory
check Checks if the generated Rust code is up-to-date
help Print this message or the help of the given subcommand(s)
Options:
--cwd <CWD> Optional working directory to run the command from
-h, --help Print help
-V, --version Print version
--cwd <path>
: Specifies a working directory to run the command from. If provided, gelx
will change to this directory before performing any operations. This is useful if you are invoking gelx
from a directory different from your project's root.The gelx
CLI tool generates Rust code from .edgeql
files located in your project. It reads configuration from your crate's Cargo.toml
file, specifically under the [package.metadata.gelx]
section.
gelx generate
Generates Rust code from the crate in the current directory
Usage: gelx generate [OPTIONS]
Options:
--json Print the generated code as JSON to stdout instead of writing to a file
--cwd <CWD> Optional working directory to run the command from
-h, --help Print help
This command generates Rust code based on your .edgeql
query files and the Gel schema.
gelx generate --cwd path/to/your/crate
Or run the command with the --json
flag to print the generated code to the terminal as JSON:
gelx generate --cwd path/to/your/crate --json
The CLI will:
[package.metadata.gelx]
in your Cargo.toml
.queries
(default: ./queries
) for .edgeql
files.--json
is used, print the combined code to the terminal as JSON.output_path
(default: ./src/db
).gelx check
Checks if the generated Rust code is up-to-date
Usage: gelx check [OPTIONS]
Options:
--cwd <CWD> Optional working directory to run the command from
-h, --help Print help
This command verifies if the currently generated code is up-to-date with your schema and query files. It's useful for CI pipelines to ensure that code generation has been run after any changes.
gelx check --cwd path/to/your/crate
The CLI will:
gelx generate
in memory.output_file
.gelx generate
needs to be run.The gelx
CLI reads its configuration from the Cargo.toml
file of the crate it is being run in. The configuration should be placed under the [package.metadata.gelx]
table.
Refer to the main gelx
crate readme.md for all the configuration options.
This crate is part of the gelx
workspace. Please refer to the main project's contributing guide for details on how to set up the development environment and contribute.
Unlicense, see the license file in the root of the workspace.