Skip to content

Wrap and indent help descriptions for options and commands - #1051

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

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

Conversation

@shadowspawn

Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

FYI: @Ephigenia

@shadowspawn

Copy link
Copy Markdown
Collaborator Author

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

Comment thread index.js
*
* @param {String} str
* @param {Number} width
* @param {Number} indent

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

@abetomo abetomo left a comment

Copy link
Copy Markdown
Collaborator

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