right alignment of numerical columns for 'triton pkgs'

This commit is contained in:
Trent Mick 2015-09-03 23:52:12 -07:00
parent de2a462f16
commit f6f0843200
2 changed files with 17 additions and 7 deletions

View File

@ -42,6 +42,13 @@ function do_packages(subcmd, opts, args, callback) {
columns = columnsDefaultLong;
}
columns = columns.split(',');
var rightAligned = {memory: true, disk: true, swap: true,
vcpus: true, lwps: true};
for (var i = 0; i < columns.length; i++) {
if (rightAligned[columns[i]]) {
columns[i] = {lookup: columns[i], align: 'right'};
}
}
var sort = opts.s.split(',');
@ -93,13 +100,16 @@ function do_packages(subcmd, opts, args, callback) {
}
if (!opts.p) {
columns = columns.map(function (c) {
switch (c) {
switch (c.lookup || c) {
case 'memory':
return {lookup: 'memoryHuman', name: 'MEMORY'};
return {lookup: 'memoryHuman', name: 'MEMORY',
align: 'right'};
case 'swap':
return {lookup: 'swapHuman', name: 'SWAP'};
return {lookup: 'swapHuman', name: 'SWAP',
align: 'right'};
case 'disk':
return {lookup: 'diskHuman', name: 'DISK'};
return {lookup: 'diskHuman', name: 'DISK',
align: 'right'};
default:
return c;
}

View File

@ -9,7 +9,7 @@
"backoff": "2.4.1",
"bigspinner": "3.1.0",
"bunyan": "1.4.0",
"cmdln": "3.2.3",
"cmdln": "git+https://github.com/trentm/node-cmdln.git#8610afe",
"dashdash": "1.10.0",
"extsprintf": "1.0.2",
"lomstream": "1.1.0",
@ -17,8 +17,8 @@
"node-uuid": "1.4.3",
"once": "1.3.2",
"restify-clients": "1.0.0",
"smartdc-auth": "git+ssh://git@github.com:joyent/node-smartdc-auth.git#3be3c1e",
"tabula": "1.4.2",
"smartdc-auth": "git+https://github.com/joyent/node-smartdc-auth.git#3be3c1e",
"tabula": "1.6.0",
"vasync": "1.6.3",
"verror": "1.6.0"
},