Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add docs

  • Loading branch information...
commit df19ff6dc320d72b9c9fde36cb83a1cb3f28e434 1 parent a3633ab
@xkxx authored
Showing with 60 additions and 14 deletions.
  1. +55 −12
  2. +5 −2 node-cli.js
@@ -2,15 +2,10 @@ Node.CLI
By SchizoDuckie
Updated By xkxx
Super simple CLI cursor position control to spice up your script's functionality in terminal/console windows
Updated for 0.4.*
Requires util
Free to use and modify.
@@ -18,43 +13,91 @@ Reporting issues is appreciated.
Node.cli uses ANSI control codes to control console behavior. For details see: <>
+See screenshot.png for an impression of what you can do.
var cli = require('./node-cli.js');
+Try node example.js to see this in action.
### cli.write(text)
Print the text to console without adding a new line after it
cli.write('We are');
cli.write('in the same line.');
### cli.print(text)
Same as cli.write(), except will add a new line
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 styles
-Choices 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.
+Choices 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'.
cli.color('yellow', cli.bold).write('Here is some yellow text.');
-Try node example.js to see this in action.
+If you are not satisfied with the provided styles, it's possible to pass SGR codes directly as . For example:
-See screenshot.png for an impression of what you can do.
+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
+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['.
7 node-cli.js
@@ -74,7 +74,7 @@ function NodeCli () {
return this.custom(output + 'm');
- //Set bckground color only
+ //Set background color only
this.bgcolor = function(color) {
return this.custom(this.bgcolors[color] + 'm');
@@ -85,7 +85,7 @@ function NodeCli () {
//Reset terminal to default attributes (colors, styles)
- this.resetColors = function() {
+ this.reset = function() {
return this.write('\x1B[0m');
@@ -165,5 +165,8 @@ function NodeCli () {
module.exports = new NodeCli();
+//Reset console when program exits
+process.on('exit', module.exports.reset);
//cli.clear().move(38, 5).write('Node.js').down(1).back(7).write('Rocks!');
module.exports.clear().move(20,20).color('red', true).write('Node.js').down(1).back(7).color('yellow', 'default', 'underscore').write('Rocks!').resetStyle().down(10);
Please sign in to comment.
Something went wrong with that request. Please try again.