Skip to content

Commit

Permalink
[lib] Add meow and chalk for cli
Browse files Browse the repository at this point in the history
- meow use minimist for parsing command line args
- chalk is used for colorful output
  • Loading branch information
at15 committed Sep 7, 2016
1 parent 98a5598 commit d2d64f0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
32 changes: 32 additions & 0 deletions bin/about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const chalk = require('chalk');
const error = chalk.bold.red;
console.log(error('Error!'));

const cli = meow(`
Usage
$ foo <input>
Options
--rainbow, -r Include a rainbow
Examples
$ foo unicorns --rainbow
🌈 unicorns 🌈
`, {
alias: {
r: 'rainbow'
}
});
/*
{
input: ['unicorns'],
flags: {rainbow: true},
...
}
*/
// node about.js unicorns --rainbow
// unicorns { rainbow: true, r: true }
console.log(cli.input[0], cli.flags);
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
"url": "https://github.com/tongquhq/about/issues"
},
"homepage": "https://github.com/tongquhq/about#readme",
"dependencies": {},
"dependencies": {
"chalk": "^1.1.3",
"meow": "^3.7.0"
},
"devDependencies": {
"chai": "3.5.0",
"coveralls": "^2.11.12",
Expand Down

0 comments on commit d2d64f0

Please sign in to comment.