Skip to content

refactor(cli): model stack as a native clap subcommand tree#1652

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/JulianMaurin/feat/rust-cli-excellence/model-stack-native-clap-subcommand-tree--ccded108
Jun 22, 2026
Merged

refactor(cli): model stack as a native clap subcommand tree#1652
mergify[bot] merged 1 commit into
mainfrom
devs/JulianMaurin/feat/rust-cli-excellence/model-stack-native-clap-subcommand-tree--ccded108

Conversation

@JulianMaurin

@JulianMaurin JulianMaurin commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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

@mergify

mergify Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 5 merge protections satisfied — ready to merge.

Show 5 satisfied protections

🟢 🤖 Continuous Integration

  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

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

🟢 Enforce conventional commit

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)(?:\(.+\))?:

🟢 🔎 Reviews

  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

  • body ~= (?ms:.{48,})

@JulianMaurin

JulianMaurin commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 refactor(cli): model stack as a native clap subcommand tree #1652 👈
2 refactor(core): preserve error sources and print the cause chain #1653
3 fix(self-update): exit with the GitHub-API code and retry transients #1654
4 feat(http): honor GitHub rate limits and bound connect time #1655
5 feat(cli): add a global --color flag and fix queue-show glyphs #1656
6 feat(cli): add a -v/-vv verbosity ladder backed by tracing #1657
7 feat(cli): generate shell completions and a man page #1658
8 test: golden-snapshot the CLI surface and guard schema drift #1659
9 refactor: dedupe the GIT_SEQUENCE_EDITOR lookup and drop port cruft #1660
10 docs(agents): rewrite AGENTS.md for the Rust workspace #1661
11 fix(cli): render stack-squash validation errors via clap #1671

@JulianMaurin JulianMaurin marked this pull request as ready for review June 19, 2026 07:13
@mergify mergify Bot requested a review from a team June 19, 2026 07:17
@JulianMaurin JulianMaurin force-pushed the devs/JulianMaurin/feat/rust-cli-excellence/resolve-junit-process-token-via-shared-auth-helper--b355c4ec branch from 3b314bd to b84d504 Compare June 19, 2026 07:52
@JulianMaurin JulianMaurin force-pushed the devs/JulianMaurin/feat/rust-cli-excellence/model-stack-native-clap-subcommand-tree--ccded108 branch from 8738916 to 6ba7b33 Compare June 19, 2026 07:52
@JulianMaurin

JulianMaurin commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 8738916 2026-06-19 07:52 UTC
2 rebase 8738916 → 6ba7b33 (rebase only) 2026-06-19 07:52 UTC
3 content 6ba7b33 → 6dbc5f9 2026-06-19 16:51 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 19, 2026 07:52 Failure
Base automatically changed from devs/JulianMaurin/feat/rust-cli-excellence/resolve-junit-process-token-via-shared-auth-helper--b355c4ec to main June 19, 2026 14:04
@mergify

mergify Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@JulianMaurin this pull request is now in conflict 😩

@mergify

mergify Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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: .github/workflows/ci.yaml (replayed onto 1e114401).

Resolve by rebasing this branch onto the latest base and pushing.

@mergify mergify Bot added the conflict label Jun 19, 2026
`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
Copilot AI review requested due to automatic review settings June 19, 2026 16:51
@JulianMaurin JulianMaurin force-pushed the devs/JulianMaurin/feat/rust-cli-excellence/model-stack-native-clap-subcommand-tree--ccded108 branch from 6ba7b33 to 6dbc5f9 Compare June 19, 2026 16:51
@mergify mergify Bot deployed to Mergify Merge Protections June 19, 2026 16:51 Active
@mergify mergify Bot removed the conflict label Jun 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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 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_stack secondary parsing with Stack(StackArgs) and a StackSubcommand enum wired directly into the main clap parse/dispatch.
  • Moves stack subcommand help text onto StackSubcommand variants; converts Stack*Cli types from derive(Parser) to derive(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.

Comment thread crates/mergify-cli/src/main.rs
Comment thread crates/mergify-cli/src/main.rs
@mergify mergify Bot requested a review from a team June 22, 2026 12:18
@mergify

mergify Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-06-22 12:49 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-06-22 12:49 UTC · at 6dbc5f9b72145ce3a895a3170a47b312ffea36af · squash

This pull request spent 21 seconds in the queue, including 5 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Jun 22, 2026
@mergify mergify Bot merged commit 8aa2ad8 into main Jun 22, 2026
23 checks passed
@mergify mergify Bot deleted the devs/JulianMaurin/feat/rust-cli-excellence/model-stack-native-clap-subcommand-tree--ccded108 branch June 22, 2026 12:49
@mergify mergify Bot removed the queued label Jun 22, 2026
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.

4 participants