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

Switch to wrap-ansi module #6

Closed
phated opened this issue Sep 26, 2015 · 10 comments
Closed

Switch to wrap-ansi module #6

phated opened this issue Sep 26, 2015 · 10 comments

Comments

@phated
Copy link

phated commented Sep 26, 2015

We are using yargs in gulp-cli and use chalk to color the descriptions. I noticed that things start to get messed up due to the wordwrap module that is utilized. I switched it out in my local install for wrap-ansi (by the chalk team) and it fixed the problem.

@bcoe
Copy link
Member

bcoe commented Sep 28, 2015

Cool, happy to make the switch.

@phated
Copy link
Author

phated commented Oct 1, 2015

It seems the tests are now failing, so there must be some differences between the 2 libraries. I don't have enough experience with wordwrap, wrap-ansi or this module to dive in. Going to cc @sindresorhus here.

@bcoe
Copy link
Member

bcoe commented Oct 4, 2015

@sindresorhus @phated had the time to sit down and look at this request, the problem I'm running into is that we'd need for wrap-ansi to have support for hard wrapping:

https://github.com/substack/node-wordwrap#wraphardstart-stop

complex multi-column layout starts to look crazy if wrapping isn't enforced at a boundary.

@sindresorhus
Copy link
Member

I've opened an issue about adding a hardwrap option: chalk/wrap-ansi#2

I probably won't have time to look into this right now, though. Maybe @Qix- @dthree does.

@dthree
Copy link

dthree commented Oct 4, 2015

@bcoe afikwrap-ansi wasn't designed to let words go beyond the boundary, i.e. I believe a semblance of "hard wrapping" is the default. It probably doesn't pad the columns where the word is shorter than the boundary, so that might be the problem.

Can you post a test string with multiple columns that reproduces the unexpected behavior?

@bcoe
Copy link
Member

bcoe commented Oct 4, 2015

see: chalk/wrap-ansi#3

@phated
Copy link
Author

phated commented Oct 5, 2015

@bcoe thanks for digging into this. Much appreciated.

@nexdrew
Copy link
Member

nexdrew commented Oct 7, 2015

Warning: shameless self-plug!

@phated If you're also interested in styling the output defined by yargs itself (e.g. 'Options:'), take a look at yargonaut - allows you to easily decorate yargs strings with chalk styles and/or figlet fonts. Some related discussion in yargs issue 251 as well.

😺

@bcoe
Copy link
Member

bcoe commented Oct 13, 2015

@phated @nexdrew I've got a pull ready to go on yargs that adds ansi color support to the UI using wrap-ansi. Could you give this branch a shot with wrap-ansi and yargonaut, and see if it does the trick for you?

@bcoe
Copy link
Member

bcoe commented Oct 16, 2015

@phated @nexdrew I've published + yargs@3.28.0 on the next tag with support for ansi escape codes, give it a shot and if things seem stable on our testing projects I'll promote it to latest:

npm install yargs@next

Have a great weekend.

@bcoe bcoe closed this as completed Oct 16, 2015
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

No branches or pull requests

5 participants