diff --git a/maxctrl/lib/core.js b/maxctrl/lib/core.js index 60d4e4c0c..6162ab5a6 100644 --- a/maxctrl/lib/core.js +++ b/maxctrl/lib/core.js @@ -102,7 +102,7 @@ module.exports.execute = function(argv, opts) { if (err) { reject(err.message) } else if (output) { - logger.log(output) + resolve(output) } }) }) diff --git a/maxctrl/maxctrl.js b/maxctrl/maxctrl.js index 1c5653b85..f1206dadb 100644 --- a/maxctrl/maxctrl.js +++ b/maxctrl/maxctrl.js @@ -15,6 +15,12 @@ var maxctrl = require('./lib/core.js') +function print(out) { + if (out) { + console.log(out) + } +} + // Mangle the arguments if we are being called from the command line if (process.argv[0] == process.execPath) { process.argv.shift() @@ -23,12 +29,4 @@ if (process.argv[0] == process.execPath) { } maxctrl.execute(process.argv) - .then(function(out) { - if (out) { - console.log(out) - } - }, function(out) { - if (out) { - console.log(out) - } - }) + .then(print, print) diff --git a/maxctrl/test/special.js b/maxctrl/test/special.js index 20ae3eb1a..415b04568 100644 --- a/maxctrl/test/special.js +++ b/maxctrl/test/special.js @@ -64,6 +64,12 @@ describe("Library invocation", function() { .should.be.rejected }) + it('command help', function() { + var opts = { extra_args: [ '--quitet'] } + return ctrl.execute('help list'.split(' '), opts) + .should.be.fulfilled + }) + it('connection failure', function() { stopMaxScale() .then(function() {