Command-line interface for the whole development cycle of Gears projects.
- Rust toolchain with
cargo(https://rust-lang.org/tools/install/) - If you want to run coverage, install
cargo-llvm-covwithcargo +stable install cargo-llvm-cov --locked
Install it from source:
cargo install cargo-gearsAfter installation, verify the command surface with:
cargo gears --helpStart by generating a new workspace:
cargo gears new /tmp/cf-demo
cd /tmp/cf-demoThe generated workspace is manifest-driven, so you should expect a
Gears.toml file alongside the runtime config files under config/.
You can run the workspace straight away with:
cargo gears run --app quickstart --env devbuild and run read generation inputs from Gears.toml, create the generated server project under the workspace
generated directory (by default .gears/<name>/), and set GEARS_CONFIG automatically for the generated project.
You can add module templates such as background-worker, api-db-handler, and api-gateway. Prefer passing
--name when you want the generated module to use your chosen name instead of the template name. For this example,
we'll use background-worker:
cargo gears generate module --template background-worker
cargo gears config mod add background-worker -c /tmp/cf-demo/config/quickstart-dev.ymlNow run it again. You should see the generated background worker outputting its sample messages:
cargo gears run --app quickstart --env devYou can run the CLI from any directory by specifying the workspace with -p. When omitted, the current directory is
used as the workspace root.
The current CLI surface is centered on Gears workspace setup, manifest-driven generation, runtime configuration, source inspection, and execution.
newinitializes a new Gears workspace from a templategenerate module --template <template>adds module templates such asbackground-worker,api-db-handler, andapi-gatewaygenerate config --template <template>creates runtime config files such asdev,prod, ordb
config mod addandconfig mod rmmanage module entries in the YAML configconfig mod db add|edit|rmmanages module-level database settingsconfig db add|edit|rmmanages shared database server definitions
Configuration commands require the path to the runtime config file with -c, for example:
cargo gears config mod add background-worker -c /tmp/cf-demo/config/app1-dev.ymlls modulesinspects available system and workspace modulesmanifest validatevalidatesGears.tomland the selected app/environment inputsmanifest lslists the manifest app/environment entries and their resolved config paths
These commands are the safest way to confirm what build, run, lint, and test will use.
buildgenerates a runnable Cargo project under the manifestworkspace.generated-dirdirectory and builds itrungenerates the same project and runs it; you can use-wfor watch mode,--otelfor OpenTelemetry, and--fipsfor the generated manifest'sfipsfeaturedeploybuilds a Docker image with the workspaceDockerfile. It requires-cand can optionally use--manifest <Cargo.toml>to build an existing manifest instead of generating one firstbuildandrunalso support--release,--clean, and--dry-run
The generated src/main.rs does not embed the config path. Instead, the generated server reads it from
GEARS_CONFIG at runtime. The CLI sets that variable for build and run, but if you execute the generated project
or compiled binary yourself, you need to set GEARS_CONFIG manually.
Example manual run of the generated project:
GEARS_CONFIG=/tmp/cf-demo/config/app1-dev.yml cargo run --manifest-path /tmp/cf-demo/.gears/app1-dev/Cargo.tomlsrcresolves Rust source for crates, modules, and items from the workspace, local cache, orcrates.iohelp schemaprints manifest, config, or module schema guidancehelp topicprints operational documentation for topics such asmanifest,generated-server,fips, andotelhelp srcis an alias forsrc
cargo gears lint --app <APP> --env <ENV> reads the selected manifest lint policy and orchestrates cargo fmt,
cargo clippy, and dylint custom rules for that workspace. It respects your custom settings from Cargo.toml.
Use --all when you want to run every available lint stage explicitly. If the CLI is built without the
dylint-rules feature, lint --dylint returns an error.
cargo gears test --app <APP> --env <ENV> is the manifest-driven test entrypoint. It passes the selected environment
config to tests through GEARS_CONFIG, and --coverage uses cargo llvm-cov with the selected runner.
At the moment, the command surface exists, but the implementation is not yet ready for general use.
cargo gears tools can install or upgrade required Rust tooling such as rustup, cargofmt, and clippy.
For the full command surface, arguments, examples, and caveats, check SKILL.md.
To run the CLI from source:
cargo run -p cargo-gears -- gears --helpThis project is licensed under the Apache License, Version 2.0.
- Full license text: LICENSE
- License URL: http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, the software is distributed on an AS IS basis, without
warranties or conditions of any kind.