Skip to content

feat(rust): generate a machine-readable CLI schema#1558

Open
JulianMaurin wants to merge 1 commit into
mainfrom
devs/JulianMaurin/cli-schema-generator/generate-machine-readable-cli-schema--6ecc1ebe
Open

feat(rust): generate a machine-readable CLI schema#1558
JulianMaurin wants to merge 1 commit into
mainfrom
devs/JulianMaurin/cli-schema-generator/generate-machine-readable-cli-schema--6ecc1ebe

Conversation

@JulianMaurin
Copy link
Copy Markdown
Contributor

@JulianMaurin JulianMaurin commented Jun 5, 2026

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

Copilot AI review requested due to automatic review settings June 5, 2026 14:22
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 5, 2026 14:22 Failure
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 5, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 👀 Review Requirements

Waiting for

  • #approved-reviews-by>=2
This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🔴 🔎 Reviews

Waiting for

  • #review-requested = 0
This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_schema module and _internal dump-cli-schema native dispatch path that prints the schema to stdout.
  • Grafts stack subcommands into the schema output (native ones via clap side-parsers; Python-shim ones via a temporary table).
  • Adds a poe build-cli-schema task and a golden test to keep crates/mergify-cli/schemas/cli-schema.json up 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.

Comment thread crates/mergify-cli/src/main.rs Outdated
Comment thread crates/mergify-cli/src/cli_schema.rs Outdated
@mergify mergify Bot requested a review from a team June 5, 2026 14:36
@JulianMaurin JulianMaurin force-pushed the devs/JulianMaurin/cli-schema-generator/generate-machine-readable-cli-schema--6ecc1ebe branch from 1d1a151 to e889eeb Compare June 5, 2026 15:09
@JulianMaurin
Copy link
Copy Markdown
Contributor Author

JulianMaurin commented Jun 5, 2026

Revision history

# Type Changes Reason Date
1 initial 1d1a151 2026-06-05 15:09 UTC
2 content 1d1a151 → e889eeb (raw) Switch to release-asset generation (Option D): schema is no longer committed in-repo — avoids churn and stack conflicts on every CLI change. release.yml now generates it from the tagged source and at… 2026-06-05 15:09 UTC
3 content e889eeb → 51dd5ce (raw) Address review: seed command.path[0] from root.get_name() instead of a hard-coded "mergify" so it can't drift from cli.name. 2026-06-05 15:12 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 5, 2026 15:10 Failure
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
@JulianMaurin JulianMaurin force-pushed the devs/JulianMaurin/cli-schema-generator/generate-machine-readable-cli-schema--6ecc1ebe branch from e889eeb to 51dd5ce Compare June 5, 2026 15:12
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 5, 2026 15:12 Failure
@mergify mergify Bot requested a review from a team June 5, 2026 15:42
@JulianMaurin JulianMaurin marked this pull request as ready for review June 5, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants