MXS-1300: Fix duplicated options

Moved the option declaration to the main source file. Added default
functions for all modules to catch unknown command invokations. Cleaned up
and exposed more ways to use the doRequest function.
This commit is contained in:
Markus Mäkelä
2017-06-30 13:21:01 +03:00
parent 63d2eee0e3
commit 38930e198d
4 changed files with 55 additions and 43 deletions

View File

@ -14,8 +14,48 @@ require('./common.js')()
'use strict';
const maxctrl_version = '1.0.0';
program
.version(maxctrl_version)
.group(['u', 'p', 'h', 'p', 'P', 's'], 'Global Options:')
.option('u', {
alias:'user',
global: true,
default: 'mariadb',
describe: 'Username to use',
type: 'string'
})
.option('p', {
alias: 'password',
describe: 'Password for the user',
default: 'admin',
type: 'string'
})
.option('h', {
alias: 'host',
describe: 'The hostname or address where MaxScale is located',
default: 'localhost',
type: 'string'
})
.option('P', {
alias: 'port',
describe: 'The port where MaxScale REST API listens on',
default: 8989,
type: 'number'
})
.option('s', {
alias: 'secure',
describe: 'Enable TLS encryption of connections',
default: 'false',
type: 'boolean'
})
.command(require('./lib/list.js'))
.command(require('./lib/show.js'))
.recommendCommands()
.help()
.demandCommand(1, 'At least one command is required')
.command('*', 'the default command', {}, () => {
console.log("Unknown command. See output of 'help' for a list of commands.")
})
.argv