fix(cli): sort top-level help with clap display order - #836
Merged
platinummonkey merged 3 commits intoSep 18, 2026
Merged
platinummonkey merged 3 commits into
platinummonkey merged 3 commits into
Conversation
Use a shared clap command constructor so generated and hand-written commands are alphabetized together in help and completions. Retarget the regression test at rendered help and cover an appended out-of-order command.
Use the shared command constructor for agent help, enforce unique top-level names and uniform display order, and make rendered-help parsing robust to wrapped descriptions and later help sections.
Prevent top-level command names and both visible and hidden aliases from colliding across hand-written and generated commands.
MintsInc
marked this pull request as ready for review
September 18, 2026 13:09
platinummonkey
approved these changes
Sep 18, 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.
Context
pup#269 established that top-level commands in
pup --helpshould be alphabetically sorted. Enum declaration order was a valid proxy while every command was hand-written, but#[command(flatten)]keeps generated commands contiguous and prevents them from being interleaved with hand-written variants.This caused pup#829 to render generated commands such as
downtimesat the end of help instead of betweendowntimeanderror-tracking.Using separate hand-written and generated blocks was considered, but clap provides only one top-level command heading, so the result would look incorrectly sorted and become more pronounced as generation expands. Assigning a shared display order lets clap sort the complete command list by name. Display order affects help placement only; command parsing is unchanged.
Clap checks duplicate command names and aliases only in debug builds. Because a duplicate top-level name or alias can behave ambiguously in release builds, this PR adds an explicit uniqueness regression test across generated and hand-written commands.
Changes
Commands:section, excluding wrapped descriptions and later help sections.Tests
cargo buildcargo fmt --checkcargo clippy --all-targets -- -D warningscargo test -- --test-threads=1— 2,018 passedpup --helpremains alphabetically sorted.pup --agent --helpstill emits the agent schema.wasm32-unknown-unknowntarget andrustupare unavailable; CI covers this configuration.