Created
September 23, 2011 07:55
-
-
Save arikon/1236927 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q'); | |
require('../lib/coa').Cmd() | |
.name(process.argv[0]) | |
.helpful() | |
.opt() | |
.name('reject').title('Returns rejected promise') | |
.long('reject') | |
.flag() | |
.act(function(opts) { | |
console.log('** doing --reject act'); | |
return this.reject('--reject act rejected promise'); | |
}) | |
.end() | |
.opt() | |
.name('ref').title('Returns resolved promise') | |
.long('ref') | |
.flag() | |
.act(function(opts) { | |
console.log('** doing --ref act'); | |
return Q.ref('--ref act resolved promise'); | |
}) | |
.end() | |
.opt() | |
.name('result').title('Returns simple result') | |
.long('result') | |
.flag() | |
.act(function(opts) { | |
console.log('** doing --result act'); | |
return '== --bla act result'; | |
}) | |
.end() | |
.act(function(opts) { | |
console.log('** doing cmd act'); | |
return '== cmd act result' | |
}) | |
.run(process.argv.slice(2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
arikon@:~/projects/bem/coa/tests (master)$ node opt-act-bug.js --reject
** doing --reject act
--reject act rejected promise
arikon@:~/projects/bem/coa/tests (master)$ node opt-act-bug.js --ref
** doing --ref act
TypeError: Cannot use 'in' operator to search for 'result' in undefined
arikon@:~/projects/bem/coa/tests (master)$ node opt-act-bug.js --result
** doing --result act
** doing cmd act
== --bla act result