UNPKG

colorprint

Version:
179 lines (111 loc) 4.72 kB
colorprint ========== <!--- This file is generated by ape-tmpl. Do not update manually. ---> <!-- Badge Start --> <a name="badges"></a> [![Build Status][bd_travis_shield_url]][bd_travis_url] [![npm Version][bd_npm_shield_url]][bd_npm_url] [![JS Standard][bd_standard_shield_url]][bd_standard_url] [bd_repo_url]: https://github.com/okunishinishi/node-colorprint [bd_travis_url]: http://travis-ci.org/okunishinishi/node-colorprint [bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-colorprint.svg?style=flat [bd_travis_com_url]: http://travis-ci.com/okunishinishi/node-colorprint [bd_travis_com_shield_url]: https://api.travis-ci.com/okunishinishi/node-colorprint.svg?token= [bd_license_url]: https://github.com/okunishinishi/node-colorprint/blob/master/LICENSE [bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-colorprint [bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-colorprint.svg?style=flat [bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-colorprint.svg?style=flat [bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-colorprint [bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-colorprint.svg [bd_npm_url]: http://www.npmjs.org/package/colorprint [bd_npm_shield_url]: http://img.shields.io/npm/v/colorprint.svg?style=flat [bd_standard_url]: http://standardjs.com/ [bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg <!-- Badge End --> <!-- Description Start --> <a name="description"></a> Print ansi-colored message to stdout/stderr. <!-- Description End --> <!-- Overview Start --> <a name="overview"></a> <img src="asset/images/screenshot.png"/> <!-- Overview End --> <!-- Sections Start --> <a name="sections"></a> <!-- Section from "doc/guides/01.Installation.md.hbs" Start --> <a name="section-doc-guides-01-installation-md"></a> Installation ----- ```bash npm install colorprint --save ``` <!-- Section from "doc/guides/01.Installation.md.hbs" End --> <!-- Section from "doc/guides/02-Usage.md.hbs" Start --> <a name="section-doc-guides-02-usage-md"></a> Usage ------- ```javascript "use strict"; const colorpint = require('colorpint') colorpint.notice('This is NOTICE') //Pipe to stdout with magenta color. colorpint.info('This is INFO') //Pipe to stdout with green color. colorpint.debug('This is DEBUG') //Pipe to stdout with color. colorpint.trace('This is TRACE') //Pipe to stdout with white color. colorpint.warn('This is WARN') //Pipe to stdout with yellow color. colorpint.error('This is ERROR') //Pipe to stderr with red color. colorpint.fatal('This is FATAL') //Pipe to stderr with bgRed color. ``` <!-- Section from "doc/guides/02-Usage.md.hbs" End --> <!-- Section from "doc/guides/03-CLI.md.hbs" Start --> <a name="section-doc-guides-03-cli-md"></a> Using via CIL ------- ### Install globally ``` $ npm install colorprint -g ``` ### From Command Line ```bash #!/bin/bash colorpint notice "This is NOTICE from CLI" # Pipe to stdout with magenta color. colorpint info "This is INFO from CLI" # Pipe to stdout with green color. colorpint debug "This is DEBUG from CLI" # Pipe to stdout with color. colorpint trace "This is TRACE from CLI" # Pipe to stdout with white color. colorpint warn "This is WARN from CLI" # Pipe to stdout with yellow color. colorpint error "This is ERROR from CLI" # Pipe to stderr with red color. colorpint fatal "This is FATAL from CLI" # Pipe to stderr with bgRed color. ``` <!-- Section from "doc/guides/03-CLI.md.hbs" End --> <!-- Section from "doc/guides/04-Customizing.md.hbs" Start --> <a name="section-doc-guides-04-customizing-md"></a> Customizing -------- ### Customize the whole module. ```javascript "use strict"; const colorprint = require('colorprint'); colorprint.PREFIX='Yeah!'; colorprint.INFO_COLOR='blue'; colorprint.info('This will be blue with prefix.'); ``` ### Create new context to customize. ```javascript "use strict"; const Colorprint = require('colorprint/lib/colorprint'); let colorprint = new Colorprint({ PREFIX: '[Foo]', INFO_COLOR: 'blue' }); colorprint.info('This will be blue with prefix.'); ``` colorprint is using [cli-color](https://github.com/medikoo/cli-color) for coloring and you can see [available colors here](https://github.com/medikoo/cli-color#colors). <!-- Section from "doc/guides/04-Customizing.md.hbs" End --> <!-- Sections Start --> <!-- LICENSE Start --> <a name="license"></a> License ------- This software is released under the [MIT License](https://github.com/okunishinishi/node-colorprint/blob/master/LICENSE). <!-- LICENSE End -->