Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Description Column not Rendering on Separate Line #88

Open
Whobeu opened this issue Sep 11, 2020 · 2 comments
Open

Issue with Description Column not Rendering on Separate Line #88

Whobeu opened this issue Sep 11, 2020 · 2 comments

Comments

@Whobeu
Copy link

Whobeu commented Sep 11, 2020

I inadvertently created an argument description that turned out to be 37 characters long. When help is displayed, the description displays as follows:

--lts, -l Download 'Long Term Support' releases[boolean] [default: false]

Personally I think it would look better if the line had a line break inserted via the _renderInLine function in order to keep the description from running into the square bracket. If the description is 38 characters in length, it will render the type and default on a separate line.

A simple change to the _renderInLine function in index.ts, changing this code:

if (leadingWhitespace < targetTextWidth) {

to this:

if (leadingWhitespace < targetTextWidth + 1) {

allows the line to break if the description is the maximum width of the field.

@bcoe
Copy link
Member

bcoe commented Sep 11, 2020

@Whobeu I feel like padding right should be able to pull this off?

@Whobeu
Copy link
Author

Whobeu commented Sep 12, 2020

I did try several ideas before focusing on cliui. Within my own module, I tried adding whitespace to the end of the description but that is trimmed off by cliui. In the help function of usage.js, I converted the "desc" argument of ui.span to an object and adding padding and width properties:

ui.span({ text: kswitch, padding: [0, 2, 0, 2], width: maxWidth(switches, theWrap) + 4 }, { text: desc, padding: [0, 2, 0, 0], width: maxWidth(descriptions, theWrap) - 1});

That worked in a sense as the description field had a break inserted in the line and wrapped to a new line. But that behavior is different from when the description is longer than 37 characters and the argument type and default are themselves on a separate line. However, the description field has a set width of 37 somewhere in the code that I did not seek out. Of course it could be increased to 38 but then a description field of 38 would exhibit the same problem then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants