MXS-2980: Forward options to the interactive mode

The --quiet option does not make sense in the interactive mode so it isn't
forwarded.

Added code that reports TLS certificate loading errors. The errors
themselves aren't very exact but at least they give a hint as to why it
failed.
This commit is contained in:
Markus Mäkelä 2020-05-06 12:24:21 +03:00
parent 0ddee9613b
commit a2b5a1aba3
No known key found for this signature in database
GPG Key ID: 5CE746D557ACC499
2 changed files with 20 additions and 3 deletions

View File

@ -369,7 +369,12 @@ module.exports = function() {
args.auth = {user: argv.u, pass: argv.p}
args.json = true
args.timeout = this.argv.timeout
setTlsCerts(args)
try {
setTlsCerts(args)
} catch (err) {
return error('Failed to set TLS certificates: ' + JSON.stringify(err, null, 4))
}
return request(args)
.then(function(res) {

View File

@ -56,7 +56,7 @@ program
})
.option('q', {
alias: 'quiet',
describe: 'Silence all output',
describe: 'Silence all output. This option is not used in the interactive mode.',
default: false,
type: 'boolean'
})
@ -123,7 +123,19 @@ program
base_opts = ['--user=' + argv.user,
'--password=' + argv.password,
'--hosts=' + argv.hosts,
'--timeout=' + argv.timeout]
'--timeout=' + argv.timeout,
'--tsv=' + argv.tsv,
'--secure=' + argv.secure,
'--tls-verify-server-cert=' + argv['tls-verify-server-cert']]
// Only set the string options if they are defined, otherwise we'll end up with the value as
// the string 'undefined'
for (i of ['tls-key', 'tls-cert', 'tls-passphrase', 'tls-ca-cert']) {
if (argv[i]) {
base_opts.push('--' + i + '=' + argv[i])
}
}
return askQuestion()
} else {
maxctrl(argv, function() {