├── screenshot.png
├── screenshot.js
├── package.json
├── .gitignore
├── README.md
├── index.js
├── LICENSE
└── screenshot.svg
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/siddharthkp/prettycli/HEAD/screenshot.png
--------------------------------------------------------------------------------
/screenshot.js:
--------------------------------------------------------------------------------
1 | const log = require('.');
2 |
3 | console.log('');
4 |
5 | log.loading('TEST', 'Running unit tests...');
6 |
7 | log.info('READY', `Server running on ${log.link('http://localhost:3000')}`);
8 |
9 | log.warn('This feature will be deprecated soon.');
10 |
11 | log.error('Could not find express. Make sure you have installed it', {
12 | exit: false
13 | });
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "prettycli",
3 | "version": "1.4.3",
4 | "description": "Pretty print messages on the terminal",
5 | "main": "index.js",
6 | "author": "siddharthkp",
7 | "bugs": {
8 | "url": "https://github.com/practo/prettycli/issues"
9 | },
10 | "license": "MIT",
11 | "repository": "siddharthkp/prettycli",
12 | "homepage": "https://github.com/siddharthkp/prettycli",
13 | "dependencies": {
14 | "chalk": "2.1.0"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # nyc test coverage
18 | .nyc_output
19 |
20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21 | .grunt
22 |
23 | # node-waf configuration
24 | .lock-wscript
25 |
26 | # Compiled binary addons (http://nodejs.org/api/addons.html)
27 | build/Release
28 |
29 | # Dependency directories
30 | node_modules
31 | jspm_packages
32 |
33 | # Optional npm cache directory
34 | .npm
35 |
36 | # Optional REPL history
37 | .node_repl_history
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Pretty print messages on the terminal
5 |
6 |
7 |
8 | #### Usage
9 |
10 | ```js
11 |
12 | // Require what you need from prettycli
13 |
14 | const {info, warn} = require('prettycli');
15 |
16 | /*
17 |
18 | There are 6 functions:
19 |
20 | Print to stdout:
21 | 1. info: (label, message)
22 | 2. loading: (label, message)
23 | 3. warn: (message)
24 | 4. error: (message)
25 |
26 | Returns pretty string (does not print)
27 | 5. command: (command)
28 | 6. link: (url)
29 |
30 | */
31 |
32 | if (!process.env.PRODUCTION) info('BUILD', 'Running dev stuff');
33 | else warn('This is production mode! Are you sure?');
34 |
35 | ```
36 |
37 |
38 |
39 | #### license
40 |
41 | MIT © [siddharthkp](https://github.com/siddharthkp)
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const chalk = require('chalk')
2 |
3 | const colorMap = {
4 | info: 'green',
5 | warn: 'yellow',
6 | loading: 'blue',
7 | error: 'red'
8 | }
9 |
10 | const print = (type, label, message) => {
11 | const color = colorMap[type]
12 | console.log(
13 | chalk.inverse.bold[color](` ${label} `),
14 | chalk[color](message),
15 | '\n'
16 | )
17 | }
18 |
19 | const info = (label, message) => print('info', label, message)
20 | const warn = message => print('warn', 'WARN', message)
21 | const loading = (label, message) => print('loading', label, message)
22 |
23 | const command = command => chalk.blue(command)
24 | const link = url => chalk.blue(url)
25 |
26 | const error = (err, options) => {
27 | const label = 'ERROR'
28 | if (!options) options = { exit: true, silent: false, label }
29 | print('error', options.label || label, err)
30 | if (options.silent) process.exit(1)
31 | if (options.exit) throw new Error(err)
32 | }
33 |
34 | module.exports = { info, loading, warn, error, command, link }
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Siddharth Kshetrapal
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/screenshot.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------