feat(help): reorganize --help into grouped, alphabetical sections#887
feat(help): reorganize --help into grouped, alphabetical sections#887FlorianBruniaux wants to merge 2 commits intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Reworks RTK’s top-level --help output by replacing Clap’s default subcommand listing with a curated, grouped help template and adds a guard test to keep the template in sync with registered commands.
Changes:
- Introduces a custom Clap
help_templatethat groups top-level commands into labeled sections with alphabetical ordering. - Reorders the
Commandsenum to match the new help layout and adds a test intended to ensure every registered subcommand appears inHELP_TEMPLATE. - Bumps version metadata to
0.34.0across Cargo + release-please + changelog artifacts.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Adds HELP_TEMPLATE, wires it into Clap, reorders subcommands, and introduces a sync test for template coverage. |
| Cargo.toml | Bumps crate version to 0.34.0. |
| Cargo.lock | Updates locked package version to 0.34.0. |
| CHANGELOG.md | Adds the 0.34.0 release entry. |
| .release-please-manifest.json | Updates release-please manifest version to 0.34.0. |
src/main.rs
Outdated
| use anyhow::{Context, Result}; | ||
| use clap::error::ErrorKind; | ||
| use clap::{Parser, Subcommand, ValueEnum}; | ||
| use clap::{CommandFactory, Parser, Subcommand, ValueEnum}; |
There was a problem hiding this comment.
CommandFactory is only used in the #[cfg(test)] module (Cli::command()), so importing it unconditionally will be unused in normal (non-test) builds and can trigger warnings/clippy findings. Consider gating the import with #[cfg(test)], or referencing the trait via clap::CommandFactory only inside the test.
| use clap::{CommandFactory, Parser, Subcommand, ValueEnum}; | |
| use clap::{Parser, Subcommand, ValueEnum}; | |
| #[cfg(test)] | |
| use clap::CommandFactory; |
| assert!( | ||
| HELP_TEMPLATE.contains(&format!(" {name}")), |
There was a problem hiding this comment.
HELP_TEMPLATE.contains(" {name}") can produce false positives when one command name is a prefix of another (e.g. hook vs hook-audit, go vs golangci-lint). This undermines the test’s goal of ensuring every command is explicitly listed. Prefer matching whole command tokens per line (e.g., iterate HELP_TEMPLATE.lines() and compare the first whitespace-delimited token to name, or search for \n {name} with a trailing delimiter).
| assert!( | |
| HELP_TEMPLATE.contains(&format!(" {name}")), | |
| let needle_prefix = format!(" {name}"); | |
| let mut found = false; | |
| for line in HELP_TEMPLATE.lines() { | |
| if let Some(stripped) = line.strip_prefix(&needle_prefix) { | |
| if stripped.is_empty() || stripped.starts_with(char::is_whitespace) { | |
| found = true; | |
| break; | |
| } | |
| } | |
| } | |
| assert!( | |
| found, |
Cargo.toml
Outdated
| [package] | ||
| name = "rtk" | ||
| version = "0.33.1" | ||
| version = "0.34.0" |
There was a problem hiding this comment.
This PR description focuses on --help reformatting, but it also bumps the crate version to 0.34.0 (and related release artifacts). If this is intended to be a release PR, the description/title should reflect that; otherwise consider moving the version/release metadata updates to the dedicated release workflow/PR to avoid accidental versioning changes.
Reorganize the flat 60-command list into readable sections: - RTK meta commands first (cc-economics through verify) - 8 alphabetical tool sections: Analysis, Build & Lint, Cloud & Infrastructure, Files & Search, Frameworks, Git & GitHub, Package Managers, Test - Unicode separator (─────) between RTK block and tool sections - Commands sorted alphabetically within each section - Sync test: help_template_covers_all_commands() prevents template/enum drift Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Florian Bruniaux <florian@bruniaux.com> Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
Adds a one-liner listing all supported ecosystems (ruff, pytest, pip, golangci-lint, etc.) in the Architecture section to satisfy the pre-push documentation validation script. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
bdc07d8 to
bd4a8fb
Compare
Summary
help_templatehelp_template_covers_all_commands()test that fails if a future command is added to the enum but not the templateBefore
After
Implementation
Uses Clap 4's
help_templateattribute on theClistruct. No external dependencies, no logic changes. The Commands enum is reordered to match (cosmetic only — Rust match arms are unaffected).The sync test uses
Cli::command().get_subcommands()to enumerate all registered commands and asserts each one appears inHELP_TEMPLATE. Adding a new command without updating the template will fail CI.Test plan
rtk --help— 9 sections, RTK first, separator line, A-Z sections, A-Z within sectionsrtk -h— same template applied to short helpcargo test— 1124 passed includinghelp_template_covers_all_commandscargo clippy --all-targets— zero warnings