Use comma separated lists in MaxCtrl options

Using commas instead of spaces prevents a the misinterpretation of
commands as hostnames. If the `--hosts` option was given just before a
command, it would consume the commands as arguments to the `--hosts` list.
This commit is contained in:
Markus Mäkelä
2018-01-10 11:00:10 +02:00
parent 882f1d719a
commit c6f7f22117
4 changed files with 13 additions and 4 deletions

View File

@ -41,8 +41,8 @@ All command accept the following global options.
-u, --user Username to use [string] [default: "admin"] -u, --user Username to use [string] [default: "admin"]
-p, --password Password for the user [string] [default: "mariadb"] -p, --password Password for the user [string] [default: "mariadb"]
-h, --hosts List of MaxScale hosts. The hosts must be in HOST:PORT format -h, --hosts List of MaxScale hosts. The hosts must be in HOST:PORT format
and each value must be separated by spaces. and each value must be separated by a comma.
[array] [default: "localhost:8989"] [string] [default: "localhost:8989"]
-s, --secure Enable HTTPS requests [boolean] [default: "false"] -s, --secure Enable HTTPS requests [boolean] [default: "false"]
-t, --timeout Request timeout in milliseconds [number] [default: "10000"] -t, --timeout Request timeout in milliseconds [number] [default: "10000"]
-q, --quiet Silence all output [boolean] [default: "false"] -q, --quiet Silence all output [boolean] [default: "false"]

View File

@ -155,6 +155,12 @@ behavior is advised.
The top filter now uses the session ID instead of an internal counter for the The top filter now uses the session ID instead of an internal counter for the
names of the log file names. names of the log file names.
### MaxCtrl
The `-h, --hosts` argument was changed to accept a list of hostnames separated
by commas instead of spaces. This prevents commands from accidentally being
interpreted as hostnames.
## Dropped Features ## Dropped Features
## New Features ## New Features

View File

@ -26,6 +26,9 @@ module.exports = function() {
// servers. // servers.
this.maxctrl = function(argv, cb) { this.maxctrl = function(argv, cb) {
// Split the hostnames, separated by commas
argv.hosts = argv.hosts.split(',')
this.argv = argv this.argv = argv
if (!argv.hosts || argv.hosts.length < 1) { if (!argv.hosts || argv.hosts.length < 1) {

View File

@ -38,9 +38,9 @@ program
.option('h', { .option('h', {
alias: 'hosts', alias: 'hosts',
describe: 'List of MaxScale hosts. The hosts must be in ' + describe: 'List of MaxScale hosts. The hosts must be in ' +
'HOST:PORT format and each value must be separated by spaces.', 'HOST:PORT format and each value must be separated by a comma.',
default: 'localhost:8989', default: 'localhost:8989',
type: 'array' type: 'string'
}) })
.option('s', { .option('s', {
alias: 'secure', alias: 'secure',