https://github.com/schizoduckie/node-cli
A super-simple class for Node.js to spice up your Node.js console output
https://github.com/schizoduckie/node-cli
Last synced: about 1 month ago
JSON representation
A super-simple class for Node.js to spice up your Node.js console output
- Host: GitHub
- URL: https://github.com/schizoduckie/node-cli
- Owner: SchizoDuckie
- Created: 2010-10-20T20:40:21.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-07-31T20:15:02.000Z (almost 13 years ago)
- Last Synced: 2025-03-17T20:45:04.018Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 120 KB
- Stars: 40
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Node.CLI
=========By SchizoDuckie
Updated By Cory Gross, xkxx
Super simple CLI cursor position control to spice up your script's functionality in terminal/console windowsUpdated for 0.4.*
v2.0
Free to use and modify.
Report any issues you encountered.Node.cli uses ANSI control codes to control console behavior. For details see:
See screenshot.png for an impression of what you can do.
Enjoy!
Usage:
-------```javascript
var cli = require('./node-cli.js');
cli.clear().move(20,20).color('red').write('Node.js').down(1).back(7).color('yellow').write('Rocks!').down(10);
```Try node example.js to see this in action.
### cli.write(text)
Print the text to console without adding a new line after itExample:
```javascript
cli.write('We are');
cli.write('in the same line.');
```### cli.print(text)
Same as cli.write(), except will add a new lineExample:
```javascript
cli.print('We are');
cli.print('In different lines');
```### cli.color(text_color, [bold(boolean or cli.bold), [background_color]])
### cli.color(text_color, [[background_color, [text_styles...]])
Set colors and stylesChoices of Text and background colors: 'default', 'gray', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'.
Choices of Text styles: 'bold', 'underscore', 'blink', 'inverse', 'conceal', 'nobold', 'nounderscore', 'noblink', 'noinverse', 'noconceal', 'frame', 'encircle', 'overline', 'no_frame_or_circle', 'nooverline'.
Example:
```javascript
cli.color('yellow', cli.bold).write('Here is some yellow text.');
```If you are not satisfied with the provided text styles, it's possible to pass SGR codes directly. For example:
```javascript
cli.color('green', 'default', 'bold', 4, 7); //same as cli.color('green', 'default', 'bold', 'underscore', 'inverse');
```### cli.bgcolor(background_color)
Set only the background color### cli.style(text_style)
Set only the text style### cli.reset()
Reset the console to default### cli.resetColor()
Reset only the text color### cli.resetBg()
Reset only the background color### cli.resetStyle()
Reset only text styles### cli.move(x, y)
Move the cursor in x,y position### cli.up(x), cli.down(x), cli.fwd(x), cli.back(x)
Move the cursor up, down, fwd or back x rows/columns### cli.clear(x)
Clear the screen. If no parameter is given or x = 2, the entire screen will be cleared; x = 0, the screen above the cursor; x = 1, the screen under the cursor### cli.clearLine(x)
Clear the line. Works similarly as cli.clear().### cli.clearNext(x)
Clear the next n letters in the line### cli.custom(command)
Save you a '\x1B['.