Skip to content

Scope subcommand usage help#22326

Merged
MikeMcQuaid merged 1 commit into
mainfrom
fix-subcommand-help-usage-errors
May 18, 2026
Merged

Scope subcommand usage help#22326
MikeMcQuaid merged 1 commit into
mainfrom
fix-subcommand-help-usage-errors

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

  • Avoid overwhelming UsageError output for commands with subcommands.
  • Keep root command help to subcommand summaries and root flags.
  • Reuse parser metadata so matched subcommands show valid flags only.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.

OpenAI Codex 5.5 xhigh with local review and testing.


Base automatically changed from fix-bundle-zap-depends-on to main May 17, 2026 19:24
@MikeMcQuaid MikeMcQuaid force-pushed the fix-subcommand-help-usage-errors branch from 8139245 to 9b86578 Compare May 17, 2026 20:13
Copilot AI review requested due to automatic review settings May 17, 2026 20:13
Copy link
Copy Markdown
Contributor

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

This PR scopes help, manpage, and shell completion output for commands with subcommands so root help shows root options/subcommand summaries while matched subcommands show their own valid flags.

Changes:

  • Adds subcommand-aware option metadata and help generation in the CLI parser.
  • Updates completions/manpage generation to use root vs subcommand-specific options.
  • Refines bundle and services option descriptions and adds regression tests.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Library/Homebrew/cli/parser.rb Adds root/subcommand option summary tracking and scoped help rendering.
Library/Homebrew/help.rb Passes usage-error context into parser help generation.
Library/Homebrew/commands.rb Returns root-only options when no subcommand is requested.
Library/Homebrew/completions.rb Generates top-level completions from root options only.
Library/Homebrew/manpages.rb Emits root options and subcommand options separately.
Library/Homebrew/bundle/subcommand/* Updates bundle option descriptions to be subcommand-specific.
Library/Homebrew/bundle/extensions/* Removes shared extension switch description helper.
Library/Homebrew/services/subcommand/* Updates services --all descriptions per operation.
Library/Homebrew/test/* Adds/updates parser, manpage, completion, bundle, and services coverage.
completions/bash/brew Regenerates bash completion output.
completions/fish/brew.fish Regenerates fish completion output.
completions/zsh/_brew Regenerates zsh completion output.
docs/Manpage.md Regenerates Markdown manpage documentation.
manpages/brew.1 Regenerates roff manpage documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/cli/parser.rb
@MikeMcQuaid MikeMcQuaid force-pushed the fix-subcommand-help-usage-errors branch from 9b86578 to b0575be Compare May 17, 2026 20:22
- Avoid overwhelming `UsageError` output for commands with subcommands.
- Keep root command help to subcommand summaries and root flags.
- Reuse parser metadata so matched subcommands show valid flags only.
- Group generated manpage options with their matching subcommands.
- Scope generated shell completions to root and subcommand flags.
- Use operation-specific flag text in help, manpages and completions.
@MikeMcQuaid MikeMcQuaid force-pushed the fix-subcommand-help-usage-errors branch from b0575be to 7b199a7 Compare May 18, 2026 06:43
@MikeMcQuaid MikeMcQuaid enabled auto-merge May 18, 2026 06:51
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit 392ac44 May 18, 2026
37 checks passed
@MikeMcQuaid MikeMcQuaid deleted the fix-subcommand-help-usage-errors branch May 18, 2026 07:30
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