ansi-escape-sequences
Advanced tools
Comparing version 2.0.0 to 2.1.0
#!/usr/bin/env node | ||
"use strict"; | ||
var ansi = require("../"); | ||
var tr = require("transform-tools"); | ||
var name = process.argv[2]; | ||
var name2 = process.argv[3]; | ||
var arg1 = process.argv[4]; | ||
var arg2 = process.argv[5]; | ||
var seq = null; | ||
process.argv.splice(0, 2); | ||
if (!process.argv.length){ | ||
console.error(ansi.format("Usage", "underline")); | ||
console.error("$ ansi <method> <args>"); | ||
console.error(); | ||
console.error(ansi.format("Example", "underline")); | ||
console.error("$ echo yeah | ansi format underline"); | ||
process.exit(1); | ||
} | ||
var method = process.argv.shift(); | ||
var args = process.argv; | ||
if (typeof ansi[name][name2] === "function"){ | ||
seq = ansi[name][name2](arg1, arg2); | ||
} else { | ||
seq = ansi[name][name2]; | ||
} | ||
if (seq !== null) { | ||
process.stdout.write(seq); | ||
} | ||
process.stdin | ||
.pipe(tr.collect({ | ||
through: function(input){ | ||
if (method === "format"){ | ||
return ansi.format(input, args); | ||
} else { | ||
console.error(ansi.format("invalid method: " + method, "red")); | ||
} | ||
} | ||
})) | ||
.pipe(process.stdout); | ||
@@ -8,3 +8,2 @@ "use strict"; | ||
/** | ||
A simple library containing all known terminal [ansi escape codes and sequences](http://en.wikipedia.org/wiki/ANSI_escape_code). Useful for adding colour to your command-line output, or building a dynamic text user interface. | ||
@exports ansi-escape-sequences | ||
@@ -11,0 +10,0 @@ @typicalname ansi |
{ | ||
"name": "ansi-escape-sequences", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A simple library containing all known terminal ansi escape codes and sequences. Useful for adding colour to your command-line output or building a dynamic text user interface.", | ||
@@ -29,3 +29,4 @@ "repository": "https://github.com/75lb/ansi-escape-sequences.git", | ||
"dependencies": { | ||
"array-tools": "^1.4.1" | ||
"array-tools": "^1.4.1", | ||
"transform-tools": "~0.1.1" | ||
}, | ||
@@ -32,0 +33,0 @@ "devDependencies": { |
@@ -6,6 +6,13 @@ [![view on npm](http://img.shields.io/npm/v/ansi-escape-sequences.svg)](https://www.npmjs.org/package/ansi-escape-sequences) | ||
<a name="module_ansi-escape-sequences"></a> | ||
# ansi-escape-sequences | ||
A simple library containing all known terminal [ansi escape codes and sequences](http://en.wikipedia.org/wiki/ANSI_escape_code). Useful for adding colour to your command-line output, or building a dynamic text user interface. | ||
## Command-line usage | ||
Format text in the terminal (bold red, in this case): | ||
<pre><code> | ||
$ echo yeah | ansi format bold red | ||
<strong>yeah</strong> | ||
</code></pre> | ||
## API Reference | ||
**Example** | ||
@@ -230,4 +237,16 @@ ```js | ||
## Install | ||
As a library: | ||
``` | ||
$ npm install ansi-escape-sequences --save | ||
``` | ||
As a command-line tool: | ||
``` | ||
$ npm install -g ansi-escape-sequences | ||
``` | ||
* * * | ||
© 2015 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown). |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20713
198
251
2
+ Addedtransform-tools@~0.1.1