MXS-2712: Move field definitions out of functions

The fields are now defined separately and no longer use the object keys as
the names of the values. This makes it clearer as to what the field
definition actually is. Following commits will add a description key into
each object that makes it possible to easily build help output.
This commit is contained in:
Markus Mäkelä
2019-10-08 12:50:39 +03:00
committed by Johan Wikman
parent 9400165376
commit 4393de42f1
3 changed files with 554 additions and 159 deletions

View File

@ -112,7 +112,7 @@ module.exports = function() {
row = []
fields.forEach(function(p) {
var v = _.getPath(i, p[Object.keys(p)[0]], '')
var v = _.getPath(i, p.path, '')
if (Array.isArray(v)) {
v = v.join(', ')
@ -162,7 +162,7 @@ module.exports = function() {
var header = []
fields.forEach(function(i) {
header.push(Object.keys(i))
header.push(i.name)
})
var table = getTable(header)
@ -188,7 +188,7 @@ module.exports = function() {
var header = []
fields.forEach(function(i) {
header.push(Object.keys(i))
header.push(i.name)
})
var table = getTable(header)
@ -197,7 +197,7 @@ module.exports = function() {
row = []
fields.forEach(function(p) {
var v = _.getPath(i, p[Object.keys(p)[0]], '')
var v = _.getPath(i, p[p.name], '')
if (Array.isArray(v) && typeof(v[0]) != 'object') {
v = v.join(', ')
@ -229,7 +229,7 @@ module.exports = function() {
separator = '\n'
var max_field_length = 0
fields.forEach(function (i) {
var k = Object.keys(i)[0]
var k = i.name
if (k.length > max_field_length) {
max_field_length = k.length
}
@ -244,8 +244,8 @@ module.exports = function() {
}
fields.forEach(function(i) {
var k = Object.keys(i)[0]
var path = i[k]
var k = i.name
var path = i.path
var v = _.getPath(data, path, '')
if (Array.isArray(v) && typeof(v[0]) != 'object') {