Skip to content

Wrap and indent help descriptions for options and commands#1051

Merged
shadowspawn merged 3 commits intotj:developfrom
shadowspawn:feature/pretty-help
Sep 22, 2019
Merged

Wrap and indent help descriptions for options and commands#1051
shadowspawn merged 3 commits intotj:developfrom
shadowspawn:feature/pretty-help

Conversation

@shadowspawn
Copy link
Collaborator

Finish off #956 with Jest tests and last fixes. See #956 for description and discussion.

(I realised when adding tests for this I have never tried the somewhat undocumented argsDescription parameter to .description, and not currently being tested here.)

Co-authored-by: Ephigenia <love@ephigenia.de>
@shadowspawn
Copy link
Collaborator Author

FYI: @Ephigenia

@shadowspawn
Copy link
Collaborator Author

No rush @abetomo, I requested review here accidentally. Thanks for other reviews already today!

*
* @param {String} str
* @param {Number} width
* @param {Number} indent
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The document parameter is missing minWidth.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prompted by this, I moved minWidth to an internal detail.

index.js Outdated
function wrap(str, width, indent) {
var regex = new RegExp('.{1,' + (width - 1) + '}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)', 'g');
var lines = str.match(regex) || [];
var result = lines.map(function(line, i) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about returning directly without assigning to a variable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@abetomo abetomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

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