feat(rust): generate a machine-readable CLI schema#1558
Open
JulianMaurin wants to merge 1 commit into
Open
Conversation
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Pull request overview
This PR adds a hidden Rust-native _internal dump-cli-schema subcommand that walks the clap command tree and emits a machine-readable JSON schema, then commits a generated cli-schema.json and pins it with a golden test so the docs site can render an always-in-sync CLI reference.
Changes:
- Introduces a
cli_schemamodule and_internal dump-cli-schemanative dispatch path that prints the schema to stdout. - Grafts
stacksubcommands into the schema output (native ones via clap side-parsers; Python-shim ones via a temporary table). - Adds a
poe build-cli-schematask and a golden test to keepcrates/mergify-cli/schemas/cli-schema.jsonup to date.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| poe.toml | Adds a Poe task to regenerate and overwrite the committed schema file. |
| crates/mergify-cli/src/main.rs | Wires the new internal subcommand into dispatch and adds a golden test for the committed schema. |
| crates/mergify-cli/src/cli_schema.rs | Implements clap tree walking + JSON serialization and stack subcommand grafting logic. |
| crates/mergify-cli/schemas/cli-schema.json | Adds the committed golden JSON output consumed by the docs site. |
| crates/mergify-cli/Cargo.toml | Adds serde dependency required for schema serialization structs. |
| Cargo.lock | Locks the new direct serde dependency for the CLI crate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1d1a151 to
e889eeb
Compare
Contributor
Author
Revision history
|
Add a hidden `_internal dump-cli-schema` subcommand that walks the clap command tree and serializes every command, argument, default, and value set to JSON — the CLI's analog of the API's OpenAPI spec, for the docs site to render. Every field comes from existing doc comments and `#[arg]`/`#[command]` attributes, so the reference cannot drift from the binary. The `stack` group's five native subcommands are grafted in (they are side-parsed outside `CliRoot`); the still-Python ones are carried in a temporary table until they port. The release workflow generates the schema from the tagged source and attaches it as a GitHub release asset for the docs sync to consume — it is generated, never committed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Change-Id: I6ecc1ebe1bb2faa002a31de2c8bebbc2ca5be0ad
e889eeb to
51dd5ce
Compare
jd
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a hidden
_internal dump-cli-schemasubcommand that walks the clapcommand tree and serializes every command, argument, default, and value
set to JSON — the CLI's analog of the API's OpenAPI spec, for the docs
site to render. Every field comes from existing doc comments and
#[arg]/#[command]attributes, so the reference cannot drift from thebinary.
The
stackgroup's five native subcommands are grafted in (they areside-parsed outside
CliRoot); the still-Python ones are carried in atemporary table until they port. The release workflow generates the
schema from the tagged source and attaches it as a GitHub release asset
for the docs sync to consume — it is generated, never committed.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com