Skip to content

Add long_desc and split -h from --help - #160

Open
aaronmallen wants to merge 1 commit into
dry-rb:mainfrom
aaronmallen:add-long-about
Open

Add long_desc and split -h from --help#160
aaronmallen wants to merge 1 commit into
dry-rb:mainfrom
aaronmallen:add-long-about

Conversation

@aaronmallen

@aaronmallen aaronmallen commented Jul 31, 2026

Copy link
Copy Markdown
Member

Commands and namespaces can now set a long description with long_desc. -h prints the
short description from desc; --help prints the long one. This mirrors how Clap treats
about and long_about in Rust.

class Echo < Dry::CLI::Command
  desc "Prints given input"
  long_desc <<~DESC
    Prints the given input back to standard output.

    When no input is given, it prints an empty line.
  DESC
end
$ foo echo -h shows "Prints given input". $ foo echo --help shows the full text.

How

  • Command and Namespace gain a long_desc class method that stores @long_description.
  • Parser registers -h and --help as separate handlers and marks the result when the
    user asked for long help.
  • Banner picks the description by help mode: long help uses long_description and falls
    back to description; short help always uses description. Multi-line text now indents
    under the Description: heading, and blank lines stay blank.
  • Command listings still use the short desc.

Compatibility

Commands without long_desc print the same output for both flags, so nothing changes for
existing CLIs. All 328 existing specs pass untouched; six new specs cover the split, the
fallback, and namespaces.

Split `-h` and `--help` handling: `-h` prints the short description set
via `desc`, while `--help` prints the long description set via the new
`long_desc` DSL (on both commands and namespaces), falling back to the
short description when unset. Command listings continue to use `desc`.
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.

1 participant