-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add resetOutput method #57
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is awesome. sorry for the slow turn around, I'm just starting to ramp up on open source again.
I'm tempted to call this method cliui.reset()
, rather than clearText()
what do you think?
README.md
Outdated
|
||
### cliui.clearText() | ||
|
||
Resets the text property of the current cliui. Wrapping, width, margin, padding, border, and align set in the constructor are not reset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset the UI elements enqueued for rendering, maintain width and wrap properties.
(unless I'm mistaken, only widt
and wrap
can be set in the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct! I will modify the readme.
@TimAConner thanks for the contribution, your change is released in |
Description
Added a resetOutput method that will clear out the text (the rows property) of the current cliui instance.
Also fixed styling issue that made my tests fail.
Problem to Solve
Before, you needed to call require('cliui')() again to clear out the text property. This would also clear out any other options you gave it. I wanted to reset the text and maintain other options already set.
Proposed Changes
Add a function named resetOutput to the UI prototype.
Expected Behavior
When you call cliui.resetOutput () the rows property will be set to [], allowing you to reset the text value but maintain the other styling / options you set without having to call require('cliui')() again.
Steps to Test Solution
Run
npm install
Add this code to a javascript file.
Run
node [your file name]
The last console log should maintain the styling but not print out the first value before it prints out 'This should print out...'
Run
npm test
to verify that all tests passed.