Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
constantology committed Feb 29, 2012
0 parents commit 296e23d
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.DS_Store

.idea/
npm-debug.log
5 changes: 5 additions & 0 deletions .npmignore
@@ -0,0 +1,5 @@
.DS_Store
.git*
.idea/

npm-debug.log
9 changes: 9 additions & 0 deletions LICENSE
@@ -0,0 +1,9 @@
(The MIT License)

Copyright (c) 2011 christos "constantology" constandinou http://muigui.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
@@ -0,0 +1,46 @@
# ansi pansi

Basic ansi formatting, foreground and background colours for use with CLIs.

## installation

```
npm install ansi-pansi
```

## usage

```javascript

var ansiformat = require( 'ansi-pansi' );

console.log( ansiformat( 'foo', 'bold blue bg_yellow' ) );
// prints => 'foo' to the console in blue, bold on a yellow background.

```

## formatting and colour options
You can use the below codes concatenated with either a plus `+` or a space ` ` character as shown in the example above.

### formatting
`bold`, `italic`, `underline`, `blink`, `reverse`, `hidden`.

### foreground colours
`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`

### background colours
`bg_black`, `bg_red`, `bg_green`, `bg_yellow`, `bg_blue`, `bg_magenta`, `bg_cyan`, `bg_white`

## License

(The MIT License)

Copyright © 2012 christos "constantology" constandinou http://muigui.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 changes: 14 additions & 0 deletions ansi-pansi.js
@@ -0,0 +1,14 @@
var code = {
reset : 0,
// formatting
bold : 1, italic : 3, underline : 4, blink : 5, reverse : 7, hidden : 8,
// foreground colours
black : 30, red : 31, green : 32, yellow : 33, blue : 34, magenta : 35, cyan : 36, white : 37,
// background colours
bg_black : 40, bg_red : 41, bg_green : 42, bg_yellow : 43, bg_blue : 44, bg_magenta : 45, bg_cyan : 46, bg_white : 47
};

exports = function ansi_pansi( str, colour ) {
var f = colour.split( /[\s\+]/ ).reduce( function( s, a ) { return ( a in code ) ? s += code[a] + ';' : s; }, '' );
return ( f.length ? '\033[' + f + 'm' : f ) + str + '\033[0m';
};
20 changes: 20 additions & 0 deletions package.json
@@ -0,0 +1,20 @@
{
"author" : {
"name" : "constantology",
"email" : "constantology@gmail.com",
"url" : "http://muigui.com"
},
"description" : "Basic ansi formatting, foreground and background colours for use with CLIs.",
"keywords" : ["ansi", "color", "colour", "cli", "console"],
"licenses" : [ {
"type" : "MIT",
"url" : "https://raw.github.com/constantology/ansi-pansi/master/LICENSE"
} ],
"main" : "./ansi-pansi.js",
"name" : "ansi-pansi",
"repository" : {
"type" : "git",
"url" : "git@github.com:constantology/ansi-pansi.git"
},
"version" : "0.0.1"
}

0 comments on commit 296e23d

Please sign in to comment.