MXS-1300: Return a rejected promise for unknown commands

When an unknow command is executed, the core should return a rejected
promise.
This commit is contained in:
Markus Mäkelä 2017-07-22 01:26:20 +03:00
parent 84dc0b2d37
commit 5edfe3040e
16 changed files with 66 additions and 35 deletions

View File

@ -44,7 +44,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: alter <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help alter` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help alter` for a list of commands.')
})
})
}

View File

@ -40,7 +40,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: call <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help call` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help call` for a list of commands.')
})
})
}

View File

@ -25,7 +25,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: clear <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help clear` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help clear` for a list of commands.')
})
})
}

View File

@ -44,6 +44,9 @@ module.exports = function() {
})
return Promise.all(promises)
.catch(function(err) {
argv.reject()
})
}, function(err) {
// One of the HTTP request pings to the cluster failed, log the error
logError(JSON.stringify(err.error, null, 4))
@ -209,7 +212,7 @@ module.exports = function() {
this.error = function(err) {
logger.log(colors.red('Error:'), err)
this.argv.reject()
return Promise.reject()
}
}

View File

@ -193,7 +193,9 @@ exports.builder = function(yargs) {
.usage('Usage: create <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help create` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help create` for a list of commands.')
})
})
}

View File

@ -39,7 +39,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: destroy <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help destroy` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help destroy` for a list of commands.')
})
})
}

View File

@ -31,8 +31,7 @@ exports.builder = function(yargs) {
})
} else {
maxctrl(argv, function() {
error('Invalid log priority: ' + argv.log)
return Promise.reject()
return error('Invalid log priority: ' + argv.log)
})
}
})
@ -43,7 +42,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: disable <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help disable` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help disable` for a list of commands.')
})
})
}

View File

@ -31,8 +31,7 @@ exports.builder = function(yargs) {
})
} else {
maxctrl(argv, function() {
error('Invalid log priority: ' + argv.log)
return Promise.reject()
return error('Invalid log priority: ' + argv.log)
})
}
})
@ -49,7 +48,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: enable <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help enable` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help enable` for a list of commands.')
})
})
}

View File

@ -43,7 +43,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: link <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help link` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help link` for a list of commands.')
})
})
}

View File

@ -103,7 +103,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: list <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help list` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help list` for a list of commands.')
})
})
}

View File

@ -24,7 +24,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: rotate <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help rotate` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help rotate` for a list of commands.')
})
})
}

View File

@ -25,7 +25,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: set <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help set` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help set` for a list of commands.')
})
})
}

View File

@ -128,7 +128,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: show <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help show` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help show` for a list of commands.')
})
})
}

View File

@ -29,7 +29,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: start <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help start` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help start` for a list of commands.')
})
})
}

View File

@ -29,7 +29,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: stop <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help stop` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help stop` for a list of commands.')
})
})
}

View File

@ -43,7 +43,9 @@ exports.builder = function(yargs) {
})
.usage('Usage: unlink <command>')
.help()
.command('*', 'the default command', {}, () => {
logger.log('Unknown command. See output of `help unlink` for a list of commands.')
.command('*', 'the default command', {}, function(argv) {
maxctrl(argv, function(host) {
return error('Unknown command. See output of `help unlink` for a list of commands.')
})
})
}