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:
@ -145,7 +145,9 @@ module.exports = function() {
|
|||||||
logError(JSON.stringify(err, null, 4))
|
logError(JSON.stringify(err, null, 4))
|
||||||
} else if (resp.statusCode == 200 && cb) {
|
} else if (resp.statusCode == 200 && cb) {
|
||||||
// Request OK, returns data
|
// Request OK, returns data
|
||||||
console.log(colors.yellow(host) + ':')
|
if (!argv.tsv) {
|
||||||
|
console.log(colors.yellow(host) + ':')
|
||||||
|
}
|
||||||
cb(res)
|
cb(res)
|
||||||
} else if (resp.statusCode == 204) {
|
} else if (resp.statusCode == 204) {
|
||||||
// Request OK, no data
|
// 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() {
|
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
|
// 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])
|
headobj[i] = colors.cyan(headobj[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Table({
|
var opts
|
||||||
head: headobj
|
|
||||||
})
|
if (this.argv.tsv)
|
||||||
|
{
|
||||||
|
opts = _.assign(opts, tsvopts)
|
||||||
|
} else {
|
||||||
|
opts = {
|
||||||
|
head: headobj
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Table(opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
function pingMaxScale(host) {
|
function pingMaxScale(host) {
|
||||||
|
@ -23,7 +23,7 @@ module.exports = function(argv) {
|
|||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
program
|
program
|
||||||
.version(maxctrl_version)
|
.version(maxctrl_version)
|
||||||
.group(['u', 'p', 'h', 's', 't'], 'Global Options:')
|
.group(['u', 'p', 'h', 's', 't', 'tsv'], 'Global Options:')
|
||||||
.option('u', {
|
.option('u', {
|
||||||
alias:'user',
|
alias:'user',
|
||||||
global: true,
|
global: true,
|
||||||
@ -56,6 +56,11 @@ module.exports = function(argv) {
|
|||||||
default: '10000',
|
default: '10000',
|
||||||
type: 'number'
|
type: 'number'
|
||||||
})
|
})
|
||||||
|
.option('tsv', {
|
||||||
|
describe: 'Print tab separated output',
|
||||||
|
default: 'false',
|
||||||
|
type: 'boolean'
|
||||||
|
})
|
||||||
|
|
||||||
.command(require('./lib/list.js'))
|
.command(require('./lib/list.js'))
|
||||||
.command(require('./lib/show.js'))
|
.command(require('./lib/show.js'))
|
||||||
|
Reference in New Issue
Block a user