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>') .usage('Usage: alter <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help alter` for a list of commands.') 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>') .usage('Usage: call <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help call` for a list of commands.') 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>') .usage('Usage: clear <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help clear` for a list of commands.') 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) return Promise.all(promises)
.catch(function(err) {
argv.reject()
})
}, function(err) { }, function(err) {
// One of the HTTP request pings to the cluster failed, log the error // One of the HTTP request pings to the cluster failed, log the error
logError(JSON.stringify(err.error, null, 4)) logError(JSON.stringify(err.error, null, 4))
@ -209,7 +212,7 @@ module.exports = function() {
this.error = function(err) { this.error = function(err) {
logger.log(colors.red('Error:'), 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>') .usage('Usage: create <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help create` for a list of commands.') 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>') .usage('Usage: destroy <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help destroy` for a list of commands.') 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 { } else {
maxctrl(argv, function() { maxctrl(argv, function() {
error('Invalid log priority: ' + argv.log) return error('Invalid log priority: ' + argv.log)
return Promise.reject()
}) })
} }
}) })
@ -43,7 +42,9 @@ exports.builder = function(yargs) {
}) })
.usage('Usage: disable <command>') .usage('Usage: disable <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help disable` for a list of commands.') 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 { } else {
maxctrl(argv, function() { maxctrl(argv, function() {
error('Invalid log priority: ' + argv.log) return error('Invalid log priority: ' + argv.log)
return Promise.reject()
}) })
} }
}) })
@ -49,7 +48,9 @@ exports.builder = function(yargs) {
}) })
.usage('Usage: enable <command>') .usage('Usage: enable <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help enable` for a list of commands.') 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>') .usage('Usage: link <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help link` for a list of commands.') 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>') .usage('Usage: list <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help list` for a list of commands.') 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>') .usage('Usage: rotate <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help rotate` for a list of commands.') 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>') .usage('Usage: set <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help set` for a list of commands.') 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>') .usage('Usage: show <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help show` for a list of commands.') 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>') .usage('Usage: start <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help start` for a list of commands.') 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>') .usage('Usage: stop <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help stop` for a list of commands.') 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>') .usage('Usage: unlink <command>')
.help() .help()
.command('*', 'the default command', {}, () => { .command('*', 'the default command', {}, function(argv) {
logger.log('Unknown command. See output of `help unlink` for a list of commands.') maxctrl(argv, function(host) {
return error('Unknown command. See output of `help unlink` for a list of commands.')
})
}) })
} }