Skip to content

feat: enhance help system with -h/--help distinction, help command, and grouping - #3

Merged
JakiChen merged 1 commit into
mainfrom
enhance-help-system
May 23, 2026
Merged

JakiChen merged 1 commit into
mainfrom
enhance-help-system

Conversation

@JakiChen

Copy link
Copy Markdown
Contributor

Summary

Enhance the help system in clippy CLI framework with the following features:

Changes

  1. Distinguish -h and --help behavior:

    • -h shows brief help (Usage + Options flags+desc + Commands) - no Arguments section, no option hints
    • --help shows detailed help (Usage + Arguments + Options with hints + Commands with usage snippets)
  2. Built-in help subcommand:

    • help → displays detailed help for current command (same as --help)
    • help <subcommand> → displays help for specified subcommand
  3. Grouping support for options and arguments:

    • Added group property to OptionDef and ArgDef types
    • Added groupOrder to HelpConfig for ordering groups
    • Added groupTitle style for styled output

Files Changed

  • src/types.ts - Added group?: string to OptionDef and ArgDef
  • src/help.ts - Enhanced HelpConfig with groupOrder, groupTitle style; formatHelp supports detailed param
  • src/command.ts - Added -h/--help distinction, help command handling, error hints use -h
  • tests/command.test.ts - Added tests for new help features
  • examples/demo.ts - Updated demo with grouped options example

Testing

  • All 37 tests pass
  • TypeScript type check passes
  • Manual verification:
    • demo -h → brief help (no Arguments, no option hints, commands without usage)
    • demo --help → detailed help (Arguments, option hints, commands with usage snippets)
    • demo help → detailed help
    • demo help serve → serve subcommand help
    • demo serve -h → brief help for subcommand

@JakiChen can click here to continue refining the PR

- -h shows brief mode: no Arguments, no option hints, commands without usage
- --help shows detailed mode: Arguments, option hints, commands with usage snippets
- Commands section hint uses -h or --help depending on mode
- Arguments section shows 'Arguments:' header in detailed mode only
- Fixed command name width calculation for proper alignment
@JakiChen
JakiChen marked this pull request as ready for review May 23, 2026 14:04
@JakiChen
JakiChen merged commit 54ddf21 into main May 23, 2026
1 check passed
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.

2 participants