refactor(cli): model stack as a native clap subcommand tree#1652
Conversation
Merge Protections🟢 All 5 merge protections satisfied — ready to merge. Show 5 satisfied protections🟢 🤖 Continuous Integration
🟢 👀 Review Requirements
🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 Reviews
🟢 📕 PR description
|
|
This pull request is part of a Mergify stack:
|
3b314bd to
b84d504
Compare
8738916 to
6ba7b33
Compare
Revision history
|
|
@JulianMaurin this pull request is now in conflict 😩 |
|
A predecessor in this stack was just merged, but I couldn't auto-rebase this PR: there's a conflict that needs human resolution. Conflict in: Resolve by rebasing this branch onto the latest base and pushing. |
`stack` was the last vestige of the Python port: a `Stack(ShimmedArgs)` catch-all (`trailing_var_arg`) whose raw argv was re-parsed by a hand-written `dispatch_stack`, with the subcommand token consumed as the program name of a secondary clap parse. No Python remains, so this was pure dead scaffolding — and it cost real UX: - `mergify stack --help` printed `Usage: stack <COMMAND>` with no subcommand descriptions; `mergify stack new --help` printed `Usage: new …`. - the global `--debug` flag was rejected on stack subcommands. - cli_schema.rs had to graft the stack subcommands in by hand (a third subcommand list that could silently drift). Model `stack` as a normal clap subcommand: `Stack(StackArgs)` with `#[command(subcommand)] command: StackSubcommand`, one variant per subcommand wrapping the existing `StackXxxCli` struct (now `derive(Args)` instead of `derive(Parser)`). Help text moves onto the variants. dispatch_from_parsed matches the variants and builds the same `NativeCommand` as before (squash keeps its fallible TryFrom → exit 2). `dispatch_stack`, `StackProbeCli`, `StackProbeSubcommand`, `ShimmedArgs`, and the cli_schema graft are deleted — the schema now comes from a uniform clap-tree walk. Net -245 lines. `mergify stack --help` now lists all 16 subcommands with descriptions, `stack <sub> --help` shows the full `mergify stack <sub>` usage, `--debug` is accepted, and the published schema can't drift from the command tree. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Change-Id: Iccded1085f318be0c9f1e243bf6d3ed1274ce08d
6ba7b33 to
6dbc5f9
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the stack command to be a first-class native clap subcommand tree instead of a trailing-argv “shim” that re-parsed arguments in a second pass. This removes dead scaffolding, improves --help/usage output, and ensures the published CLI schema is generated from a single uniform clap tree (preventing drift).
Changes:
- Replaces the
Stack(ShimmedArgs)+dispatch_stacksecondary parsing withStack(StackArgs)and aStackSubcommandenum wired directly into the main clap parse/dispatch. - Moves
stacksubcommand help text ontoStackSubcommandvariants; convertsStack*Clitypes fromderive(Parser)toderive(Args). - Simplifies CLI schema generation by deleting the special-case grafting of stack subcommands and relying on the normal clap tree walk.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/mergify-cli/src/main.rs | Refactors stack into a native clap subcommand tree and updates dispatch/help plumbing accordingly. |
| crates/mergify-cli/src/cli_schema.rs | Removes the stack-specific schema graft; schema now comes entirely from the clap command tree. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 21 seconds in the queue, including 5 seconds running CI. Required conditions to merge
|
stackwas the last vestige of the Python port: aStack(ShimmedArgs)catch-all (
trailing_var_arg) whose raw argv was re-parsed by ahand-written
dispatch_stack, with the subcommand token consumed asthe program name of a secondary clap parse. No Python remains, so this
was pure dead scaffolding — and it cost real UX:
mergify stack --helpprintedUsage: stack <COMMAND>with nosubcommand descriptions;
mergify stack new --helpprintedUsage: new ….--debugflag was rejected on stack subcommands.(a third subcommand list that could silently drift).
Model
stackas a normal clap subcommand:Stack(StackArgs)with#[command(subcommand)] command: StackSubcommand, one variant persubcommand wrapping the existing
StackXxxClistruct (nowderive(Args)instead ofderive(Parser)). Help text moves onto thevariants. dispatch_from_parsed matches the variants and builds the
same
NativeCommandas before (squash keeps its fallible TryFrom →exit 2).
dispatch_stack,StackProbeCli,StackProbeSubcommand,ShimmedArgs, and the cli_schema graft are deleted — the schema nowcomes from a uniform clap-tree walk. Net -245 lines.
mergify stack --helpnow lists all 16 subcommands with descriptions,stack <sub> --helpshows the fullmergify stack <sub>usage,--debugis accepted, and the published schema can't drift from thecommand tree.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com