From f6f08432005946df468d89661935830df2223a4b Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 3 Sep 2015 23:52:12 -0700 Subject: [PATCH] right alignment of numerical columns for 'triton pkgs' --- lib/do_packages.js | 18 ++++++++++++++---- package.json | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/do_packages.js b/lib/do_packages.js index f423e35..70cb7f2 100644 --- a/lib/do_packages.js +++ b/lib/do_packages.js @@ -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; } diff --git a/package.json b/package.json index f477f4a..782acf9 100644 --- a/package.json +++ b/package.json @@ -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" },