Separate MaxCtrl create options
The options for each command are now declared "inside" the command. This makes the help output a lot clearer and only displays the options relevant for the command in question.
This commit is contained in:
@ -36,13 +36,29 @@ exports.desc = 'Create objects'
|
||||
exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
// Common options
|
||||
.group(['protocol', 'authenticator', 'authenticator-options', 'tls-key',
|
||||
'tls-cert', 'tls-ca-cert', 'tls-version', 'tls-cert-verify-depth'],
|
||||
'Common create options:')
|
||||
// Create server
|
||||
.command('server <name> <host|socket> [port]', 'Create a new server', function(yargs) {
|
||||
return yargs.epilog('The created server will not be used by any services or monitors ' +
|
||||
'unless the --services or --monitors options are given. The list ' +
|
||||
'of servers a service or a monitor uses can be altered with the ' +
|
||||
'`link` and `unlink` commands. If the <host|socket> argument is an ' +
|
||||
'absolute path, the server will use a local UNIX domain socket ' +
|
||||
'connection. In this case the [port] argument is ignored.')
|
||||
.usage('Usage: create server <name> <host|socket> [port]')
|
||||
.group(['services', 'monitors', 'protocol', 'authenticator', 'authenticator-options',
|
||||
'tls-key', 'tls-cert', 'tls-ca-cert', 'tls-version'], 'Create server options:')
|
||||
.option('services', {
|
||||
describe: 'Link the created server to these services',
|
||||
type: 'array'
|
||||
})
|
||||
.option('monitors', {
|
||||
describe: 'Link the created server to these monitors',
|
||||
type: 'array'
|
||||
})
|
||||
.option('protocol', {
|
||||
describe: 'Protocol module name',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
default: 'mariadbbackend'
|
||||
})
|
||||
.option('authenticator', {
|
||||
describe: 'Authenticator module name',
|
||||
@ -73,24 +89,6 @@ exports.builder = function(yargs) {
|
||||
type: 'string'
|
||||
})
|
||||
|
||||
// Create server
|
||||
.group(['services', 'monitors'], 'Create server options:')
|
||||
.option('services', {
|
||||
describe: 'Link the created server to these services',
|
||||
type: 'array'
|
||||
})
|
||||
.option('monitors', {
|
||||
describe: 'Link the created server to these monitors',
|
||||
type: 'array'
|
||||
})
|
||||
.command('server <name> <host|socket> [port]', 'Create a new server', function(yargs) {
|
||||
return yargs.epilog('The created server will not be used by any services or monitors ' +
|
||||
'unless the --services or --monitors options are given. The list ' +
|
||||
'of servers a service or a monitor uses can be altered with the ' +
|
||||
'`link` and `unlink` commands. If the <host|socket> argument is an ' +
|
||||
'absolute path, the server will use a local UNIX domain socket ' +
|
||||
'connection. In this case the [port] argument is ignored.')
|
||||
.usage('Usage: create server <name> <host|socket> [port]')
|
||||
}, function(argv) {
|
||||
var server = {
|
||||
'data': {
|
||||
@ -136,6 +134,12 @@ exports.builder = function(yargs) {
|
||||
})
|
||||
|
||||
// Create monitor
|
||||
.command('monitor <name> <module> [params...]', 'Create a new monitor', function(yargs) {
|
||||
return yargs.epilog('The list of servers given with the --servers option should not ' +
|
||||
'contain any servers that are already monitored by another monitor. ' +
|
||||
'The last argument to this command is a list of key=value parameters ' +
|
||||
'given as the monitor parameters.')
|
||||
.usage('Usage: create monitor <name> <module> [params...]')
|
||||
.group(['servers', 'monitor-user', 'monitor-password'], 'Create monitor options:')
|
||||
.option('servers', {
|
||||
describe: 'Link the created monitor to these servers',
|
||||
@ -149,12 +153,7 @@ exports.builder = function(yargs) {
|
||||
describe: 'Password for the monitor user',
|
||||
type: 'string'
|
||||
})
|
||||
.command('monitor <name> <module> [params...]', 'Create a new monitor', function(yargs) {
|
||||
return yargs.epilog('The list of servers given with the --servers option should not ' +
|
||||
'contain any servers that are already monitored by another monitor. ' +
|
||||
'The last argument to this command is a list of key=value parameters ' +
|
||||
'given as the monitor parameters.')
|
||||
.usage('Usage: create monitor <name> <module> [params...]')
|
||||
|
||||
}, function(argv) {
|
||||
|
||||
var monitor = {
|
||||
@ -195,6 +194,11 @@ exports.builder = function(yargs) {
|
||||
})
|
||||
|
||||
// Create service
|
||||
.command('service <name> <router> <params...>', 'Create a new service', function(yargs) {
|
||||
return yargs.epilog('The last argument to this command is a list of key=value parameters ' +
|
||||
'given as the service parameters. If the --servers or --filters options ' +
|
||||
'are used, they must be defined after the service parameters.')
|
||||
.usage('Usage: service <name> <router> <params...>')
|
||||
.group(['servers', 'filters'], 'Create service options:')
|
||||
.option('servers', {
|
||||
describe: 'Link the created service to these servers',
|
||||
@ -204,11 +208,7 @@ exports.builder = function(yargs) {
|
||||
describe: 'Link the created service to these filters',
|
||||
type: 'array'
|
||||
})
|
||||
.command('service <name> <router> <params...>', 'Create a new service', function(yargs) {
|
||||
return yargs.epilog('The last argument to this command is a list of key=value parameters ' +
|
||||
'given as the service parameters. If the --servers or --filters options ' +
|
||||
'are used, they must be defined after the service parameters.')
|
||||
.usage('Usage: service <name> <router> <params...>')
|
||||
|
||||
}, function(argv) {
|
||||
maxctrl(argv, function(host) {
|
||||
|
||||
@ -274,15 +274,50 @@ exports.builder = function(yargs) {
|
||||
})
|
||||
|
||||
// Create listener
|
||||
.group(['interface'], 'Create listener options:')
|
||||
.command('listener <service> <name> <port>', 'Create a new listener', function(yargs) {
|
||||
return yargs.epilog('The new listener will be taken into use immediately.')
|
||||
.usage('Usage: create listener <service> <name> <port>')
|
||||
.group(['interface', , 'protocol', 'authenticator', 'authenticator-options', 'tls-key', 'tls-cert', 'tls-ca-cert', 'tls-version'],
|
||||
'Create listener options:')
|
||||
.option('interface', {
|
||||
describe: 'Interface to listen on',
|
||||
type: 'string',
|
||||
default: '::'
|
||||
})
|
||||
.command('listener <service> <name> <port>', 'Create a new listener', function(yargs) {
|
||||
return yargs.epilog('The new listener will be taken into use immediately.')
|
||||
.usage('Usage: create listener <service> <name> <port>')
|
||||
.option('protocol', {
|
||||
describe: 'Protocol module name',
|
||||
type: 'string',
|
||||
default: 'mariadbclient'
|
||||
})
|
||||
.option('authenticator', {
|
||||
describe: 'Authenticator module name',
|
||||
type: 'string'
|
||||
})
|
||||
.option('authenticator-options', {
|
||||
describe: 'Option string for the authenticator',
|
||||
type: 'string'
|
||||
})
|
||||
.option('tls-key', {
|
||||
describe: 'Path to TLS key',
|
||||
type: 'string'
|
||||
})
|
||||
.option('tls-cert', {
|
||||
describe: 'Path to TLS certificate',
|
||||
type: 'string'
|
||||
})
|
||||
.option('tls-ca-cert', {
|
||||
describe: 'Path to TLS CA certificate',
|
||||
type: 'string'
|
||||
})
|
||||
.option('tls-version', {
|
||||
describe: 'TLS version to use',
|
||||
type: 'string'
|
||||
})
|
||||
.option('tls-cert-verify-depth', {
|
||||
describe: 'TLS certificate verification depth',
|
||||
type: 'string'
|
||||
})
|
||||
|
||||
}, function(argv) {
|
||||
maxctrl(argv, function(host) {
|
||||
|
||||
@ -314,6 +349,12 @@ exports.builder = function(yargs) {
|
||||
return doRequest(host, 'services/' + argv.service + '/listeners', null, {method: 'POST', body: listener})
|
||||
})
|
||||
})
|
||||
.command('user <name> <password>', 'Create a new network user', function(yargs) {
|
||||
return yargs.epilog('The created user can be used with the MaxScale REST API as ' +
|
||||
'well as the MaxAdmin network interface. By default the created ' +
|
||||
'user will have read-only privileges. To make the user an ' +
|
||||
'administrative user, use the `--type=admin` option.')
|
||||
.usage('Usage: create user <name> <password>')
|
||||
.group(['type'], 'Create user options:')
|
||||
.option('type', {
|
||||
describe: 'Type of user to create',
|
||||
@ -321,12 +362,6 @@ exports.builder = function(yargs) {
|
||||
default: 'basic',
|
||||
choices: ['admin', 'basic']
|
||||
})
|
||||
.command('user <name> <password>', 'Create a new network user', function(yargs) {
|
||||
return yargs.epilog('The created user can be used with the MaxScale REST API as ' +
|
||||
'well as the MaxAdmin network interface. By default the created ' +
|
||||
'user will have read-only privileges. To make the user an ' +
|
||||
'administrative user, use the `--type=admin` option.')
|
||||
.usage('Usage: create user <name> <password>')
|
||||
}, function(argv) {
|
||||
|
||||
var user = {
|
||||
|
Reference in New Issue
Block a user