MXS-1300: Add TSV output to MaxCtrl
TSV output is a lot easier to parse compared to the pretty-printed Unicode.
This commit is contained in:
parent
816e317485
commit
b54e94ce95
@ -145,7 +145,9 @@ module.exports = function() {
|
||||
logError(JSON.stringify(err, null, 4))
|
||||
} else if (resp.statusCode == 200 && cb) {
|
||||
// Request OK, returns data
|
||||
console.log(colors.yellow(host) + ':')
|
||||
if (!argv.tsv) {
|
||||
console.log(colors.yellow(host) + ':')
|
||||
}
|
||||
cb(res)
|
||||
} else if (resp.statusCode == 204) {
|
||||
// Request OK, no data
|
||||
@ -178,8 +180,33 @@ module.exports = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var tsvopts = {
|
||||
chars: {
|
||||
'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': ''
|
||||
, 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': ''
|
||||
, 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': ''
|
||||
, 'right': '' , 'right-mid': '' , 'middle': ' '
|
||||
},
|
||||
style: {
|
||||
'padding-left': 0,
|
||||
'padding-right': 0,
|
||||
compact: true
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getList() {
|
||||
return new Table({ style: { head: ['cyan'] } })
|
||||
var opts = {
|
||||
style: { head: ['cyan'] }
|
||||
}
|
||||
|
||||
if (this.argv.tsv)
|
||||
{
|
||||
opts = _.assign(opts, tsvopts)
|
||||
}
|
||||
|
||||
return new Table(opts)
|
||||
}
|
||||
|
||||
// Creates a table-like array for output. The parameter is an array of header names
|
||||
@ -189,9 +216,18 @@ function getTable(headobj) {
|
||||
headobj[i] = colors.cyan(headobj[i])
|
||||
}
|
||||
|
||||
return new Table({
|
||||
head: headobj
|
||||
})
|
||||
var opts
|
||||
|
||||
if (this.argv.tsv)
|
||||
{
|
||||
opts = _.assign(opts, tsvopts)
|
||||
} else {
|
||||
opts = {
|
||||
head: headobj
|
||||
}
|
||||
}
|
||||
|
||||
return new Table(opts)
|
||||
}
|
||||
|
||||
function pingMaxScale(host) {
|
||||
|
@ -23,7 +23,7 @@ module.exports = function(argv) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
program
|
||||
.version(maxctrl_version)
|
||||
.group(['u', 'p', 'h', 's', 't'], 'Global Options:')
|
||||
.group(['u', 'p', 'h', 's', 't', 'tsv'], 'Global Options:')
|
||||
.option('u', {
|
||||
alias:'user',
|
||||
global: true,
|
||||
@ -56,6 +56,11 @@ module.exports = function(argv) {
|
||||
default: '10000',
|
||||
type: 'number'
|
||||
})
|
||||
.option('tsv', {
|
||||
describe: 'Print tab separated output',
|
||||
default: 'false',
|
||||
type: 'boolean'
|
||||
})
|
||||
|
||||
.command(require('./lib/list.js'))
|
||||
.command(require('./lib/show.js'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user