rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.13k stars 552 forks source link

🌧️ long_desc: new option to disable wrapping #739

Closed igneus closed 1 year ago

igneus commented 4 years ago

What it does

The PR implements this suggestion from the #398 comments. long_desc now receives a new option wrap. Setting it to false disables wrapping of the long description and prints it verbatim.

long_desc <<~MSG, wrap: false
  formatted text that is not wrapped
 ...
MSG

What it breaks

It adds a new obligatory constructor argument to Thor::Command. If the constructor is considered part of the public API, this may be a problem.

(I did read CONTRIBUTING.md, but I prefer not to use the rainbow emoji because of the meanings it usually carries nowadays, hence the cloud in PR title.)

igneus commented 4 years ago

If the change of Thor::Command constructor argument count were undesired, an alternative proposal would be to preserve the original argument count, but change the type of long_description from String to String|Hash, where the Hash form would allow passing presentation settings alongside text in a single argument. Like

Thor::Command.new('name', 'Description', {text: 'Long description ...', wrap: false}, nil, nil)

This would be 100% backward-compatible and would allow eventually adding more long_desc presentation settings in future.