Skip to content

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

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 without usage) - 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
  4. Subcommand usage snippets:

    • Each subcommand shows its own [options] and args in detailed mode
    • In brief mode (-h), subcommands show only name without usage

Files Changed

  • src/types.ts - Added group?: string to OptionDef and ArgDef
  • src/help.ts - Enhanced HelpConfig with groupOrder, groupTitle style; SubcommandInfo now includes options/args
  • 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
  • Manual verification:
    • demo -h → brief help (no Arguments, no option hints, commands without usage)
    • demo --help → detailed help (Arguments, option hints, commands with usage like deploy [options] <env> [tag])
    • demo help → detailed help
    • demo help serve → serve subcommand help

@JakiChen can click here to continue refining the PR

- Added options and args fields to SubcommandInfo interface
- In detailed mode, commands show their own [options] and args
- In brief mode (-h), commands show only name without usage
- deploy now shows: deploy [options] <env> [tag]
@JakiChen
JakiChen marked this pull request as ready for review May 23, 2026 15:01
@JakiChen
JakiChen merged commit 5e462ad 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