diff --git a/bin/npm-scripts-info b/bin/npm-scripts-info index b78899d..a5e01d7 100644 --- a/bin/npm-scripts-info +++ b/bin/npm-scripts-info @@ -1,12 +1,27 @@ #!/usr/bin/env node -var chalk = require('chalk'); var info = require('../lib'); +var meow = require('meow'); var scripts = info(); -for ( var script in scripts ) { - var description = scripts[script]; +var cli = meow([ + 'Usage', + ' npm-scripts-info [hr]', + '', + 'Options', + ' --help, -h Display usage', + ' --reporter, -r Specify the custom reporter to be used', + '', + 'Examples', + ' npm-scripts-info -r=my-reporter' +].join('\n'), { + string: ['reporter'], + alias: { + reporter: 'r', + help: 'h' + } +}); - console.log(chalk.blue(script) + ':'); - console.log(' ' + chalk.green(description)); -} \ No newline at end of file +cli.flags.reporter + ? require('npm-scripts-info-' + cli.flags.reporter)(scripts) + : require('../lib/reporter')(scripts); \ No newline at end of file diff --git a/lib/reporter.js b/lib/reporter.js new file mode 100644 index 0000000..a919ad8 --- /dev/null +++ b/lib/reporter.js @@ -0,0 +1,12 @@ +var chalk = require('chalk'); + +function reporter(scripts) { + for ( var script in scripts ) { + var description = scripts[script]; + + console.log(chalk.blue(script) + ':'); + console.log(' ' + chalk.green(description)); + } +} + +module.exports = reporter; \ No newline at end of file diff --git a/package.json b/package.json index c832148..47888b6 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "rewire": "^2.5.1" }, "dependencies": { - "chalk": "^1.1.1" + "chalk": "^1.1.1", + "meow": "^3.7.0" } }