From 8f7fa3ac90446a5abccb56208fdbd2f26490726d Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 25 Aug 2015 13:13:54 -0700 Subject: [PATCH] forgot to add --- lib/do_profile.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lib/do_profile.js diff --git a/lib/do_profile.js b/lib/do_profile.js new file mode 100644 index 0000000..48555ea --- /dev/null +++ b/lib/do_profile.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015 Joyent Inc. All rights reserved. + * + * `triton profile ...` + */ + +var common = require('./common'); + + + +function do_profile (subcmd, opts, args, callback) { + if (opts.help) { + this.do_help('help', {}, [subcmd], callback); + return; + } else if (args.length > 1) { + return callback(new Error('too many args: ' + args)); + } + + var profs = common.deepObjCopy(this.sdc.profiles); + var currProfileName = this.sdc.profile.name; + for (var i = 0; i < profs.length; i++) { + profs[i].curr = (profs[i].name === currProfileName ? '*' : ' '); + profs[i].dcs = (profs[i].dcs ? profs[i].dcs : ['all']) + .join(','); + } + if (opts.json) { + p(JSON.stringify(profs, null, 4)); + } else { + common.tabulate(profs, { + columns: 'curr,name,dcs,user,keyId', + sort: 'name,user', + validFields: 'curr,name,dcs,user,keyId' + }); + } + callback(); +}; + +do_profile.options = [ + { + names: ['help', 'h'], + type: 'bool', + help: 'Show this help.' + }, + { + names: ['json', 'j'], + type: 'bool', + help: 'JSON output.' + } +]; +do_profile.help = ( + 'Create, update or inpect joyent CLI profiles.\n' + + '\n' + + 'Usage:\n' + + ' {{name}} profile\n' + + '\n' + + '{{options}}' +); + + +module.exports = do_profile; \ No newline at end of file