cac
Advanced tools
Comparing version 0.1.0 to 1.0.0
16
index.js
@@ -45,4 +45,7 @@ 'use strict' | ||
_.command = function (name, fn) { | ||
this.commands[name] = fn | ||
this.rawCommands.push(name) | ||
name.split(',').forEach(val => { | ||
val = val.trim() | ||
this.commands[val] = fn | ||
this.rawCommands.push(val) | ||
}) | ||
} | ||
@@ -93,6 +96,7 @@ | ||
flags: this.argv.flags, | ||
showHelp: this.showHelp | ||
showHelp: this.showHelp.bind(this), | ||
rawCommands: this.rawCommands | ||
} | ||
if (isGeneratorFunction(commandFn)) { | ||
co(commandFn.bind(context)) | ||
co(commandFn.bind(context)).catch(this.onError.bind(context)) | ||
} else { | ||
@@ -114,2 +118,6 @@ commandFn.call(context) | ||
_.onError = function (e) { | ||
console.log(e.stack || e.message || e.name) | ||
} | ||
module.exports = Cac |
{ | ||
"name": "cac", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Command And Conquer.", | ||
@@ -16,3 +16,5 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "xo && nyc ava" | ||
"test": "xo && nyc ava", | ||
"example:help": "node examples/help -h", | ||
"example:alias-command": "node examples/alias-command r" | ||
}, | ||
@@ -19,0 +21,0 @@ "files": [ |
@@ -13,3 +13,3 @@ # CAC [![NPM version](https://img.shields.io/npm/v/cac.svg)](https://npmjs.com/package/cac) [![NPM downloads](https://img.shields.io/npm/dm/cac.svg)](https://npmjs.com/package/cac) [![Build Status](https://img.shields.io/circleci/project/egoist/cac/master.svg)](https://circleci.com/gh/egoist/cac) [![Coveralls branch](https://img.shields.io/coveralls/egoist/cac/master.svg)](https://github.com/egoist/cac) | ||
- [x] Support [co](https://github.com/tj/co) flow | ||
- [ ] Well tested | ||
- [x] Well tested | ||
@@ -34,2 +34,5 @@ ## Install | ||
Commands: | ||
c, create Create a file with specific content | ||
Options: | ||
@@ -45,7 +48,7 @@ -m, --message File content | ||
cli.command('create', function* () { | ||
cli.command('c, create', function* () { | ||
const fileName = this.input[1] | ||
const content = this.flags.message | ||
yield fs.createFile(fileName, 'hello') | ||
console.log('Done'! | ||
console.log('Done!') | ||
}) | ||
@@ -52,0 +55,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6771
103
1
84