Skip to content

feat(help): reorganize --help into grouped, alphabetical sections#887

Open
FlorianBruniaux wants to merge 2 commits intodevelopfrom
feature/help-reorganize
Open

feat(help): reorganize --help into grouped, alphabetical sections#887
FlorianBruniaux wants to merge 2 commits intodevelopfrom
feature/help-reorganize

Conversation

@FlorianBruniaux
Copy link
Copy Markdown
Collaborator

Summary

  • Groups 60 commands into 9 labeled sections via a custom help_template
  • RTK meta commands appear first; tool sections are alphabetical (Analysis → Build & Lint → Cloud & Infrastructure → Files & Search → Frameworks → Git & GitHub → Package Managers → Test)
  • Commands are alphabetical within each section
  • Adds a help_template_covers_all_commands() test that fails if a future command is added to the enum but not the template

Before

Commands:
  ls             List directory contents with token-optimized output (proxy to native ls)
  tree           Directory tree with token-optimized output (proxy to native tree)
  read           Read file with intelligent filtering
  smart          Generate 2-line technical summary (heuristic-based)
  git            Git commands with compact output
  gh             GitHub CLI (gh) commands with token-optimized output
  aws            AWS CLI with compact output (force JSON, compress)
  psql           PostgreSQL client with compact output (strip borders, compress tables)
  pnpm           pnpm commands with ultra-compact output
  err            Run command and show only errors/warnings
  test           Run tests and show only failures
  ... 49 more commands in no particular order

After

RTK:
  cc-economics   Spending vs savings analysis
  config         Show/create configuration
  discover       Find missed savings opportunities
  gain           Token savings summary and history
  hook           Hook processors for AI tools
  hook-audit     Hook rewrite audit metrics
  init           Initialize rtk for your AI agent
  learn          Learn from CLI error history
  proxy          Execute without filtering (track only)
  rewrite        Rewrite command to RTK equivalent
  session        RTK adoption across sessions
  trust          Trust project TOML filters
  untrust        Revoke TOML filter trust
  verify         Verify hook + TOML filters

─────────────────────────────────────────────────────────

Analysis:
  deps / env / err / json / log / smart / summary

Build & Lint:
  cargo / dotnet / format / go / golangci-lint / lint / mypy / prettier / rubocop / ruff / tsc

Cloud & Infrastructure:
  aws / curl / docker / kubectl / psql / wget

Files & Search:
  diff / find / grep / ls / read / tree / wc

Frameworks:
  next / prisma

Git & GitHub:
  gh / git / gt

Package Managers:
  npm / npx / pip / pnpm

Test:
  playwright / pytest / rake / rspec / test / vitest

Implementation

Uses Clap 4's help_template attribute on the Cli struct. 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 in HELP_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 sections
  • rtk -h — same template applied to short help
  • cargo test — 1124 passed including help_template_covers_all_commands
  • cargo clippy --all-targets — zero warnings
  • No logic changes, no new dependencies

Copilot AI review requested due to automatic review settings March 27, 2026 23:13
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 27, 2026

CLA assistant check
All committers have signed the CLA.

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

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_template that groups top-level commands into labeled sections with alphabetical ordering.
  • Reorders the Commands enum to match the new help layout and adds a test intended to ensure every registered subcommand appears in HELP_TEMPLATE.
  • Bumps version metadata to 0.34.0 across 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};
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
use clap::{CommandFactory, Parser, Subcommand, ValueEnum};
use clap::{Parser, Subcommand, ValueEnum};
#[cfg(test)]
use clap::CommandFactory;

Copilot uses AI. Check for mistakes.
Comment on lines +2749 to +2750
assert!(
HELP_TEMPLATE.contains(&format!(" {name}")),
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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,

Copilot uses AI. Check for mistakes.
Cargo.toml Outdated
[package]
name = "rtk"
version = "0.33.1"
version = "0.34.0"
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
FlorianBruniaux and others added 2 commits March 28, 2026 00:30
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>
@FlorianBruniaux FlorianBruniaux force-pushed the feature/help-reorganize branch from bdc07d8 to bd4a8fb Compare March 27, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants