I think there is a small disconnect with how cli-easy works. Here's a sample from cli-easy-uname-test.js:
CLIEasy.describe('uname test')
.use('uname')
.discuss('calling without arguments')
.run()
.expect('should return Linux', 'Linux\n')
.undiscuss()
.discuss('calling with -p')
.arg('-p')
.run()
.expect('should return current arch type', /x86_64/)
.undiscuss()
.discuss('calling with -r')
.arg('-r')
.run()
.expect('should return kernel version', function(version) {
var re = /^(\d+)\.(\d+)\.(\d+)\-(\d+)-([^\d]+)\n$/,
match = version.match(re);
if (match === null) return false;
if (parseInt(match[1]) < 2) return false;
return true;
})
.undiscuss()
.discuss('calling with wrong arguments')
.arg('-wrong-arg')
.run('-another-wrong-arg')
.expect('should exit with code = 1', null, 1)
.expect('should write to stderr', null, /invalid option/)
.undiscuss()
.export(module);
I think this usage should be:
CLIEasy.describe('uname test')
.use('uname')
.discuss('calling without arguments')
.expect('should return Linux', 'Linux\n')
.undiscuss()
.discuss('calling with -p')
.arg('-p')
.expect('should return current arch type', /x86_64/)
.undiscuss()
.discuss('calling with -r')
.arg('-r')
.expect('should return kernel version', function(version) {
var re = /^(\d+)\.(\d+)\.(\d+)\-(\d+)-([^\d]+)\n$/,
match = version.match(re);
if (match === null) return false;
if (parseInt(match[1]) < 2) return false;
return true;
})
.undiscuss()
.discuss('calling with wrong arguments')
.arg('-wrong-arg')
.arg('-another-wrong-arg')
.expect('should exit with code = 1', null, 1)
.expect('should write to stderr', null, /invalid option/)
.undiscuss()
.export(module);
Notice how I have removed all references to .run(). This is how api-easy works.
I think there is a small disconnect with how
cli-easyworks. Here's a sample fromcli-easy-uname-test.js:I think this usage should be:
Notice how I have removed all references to
.run(). This is howapi-easyworks.