2015-08-25 23:13:54 +03:00
|
|
|
/*
|
2015-09-04 21:12:20 +03:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2015 Joyent, Inc.
|
2015-08-25 23:13:54 +03:00
|
|
|
*
|
|
|
|
* `triton profile ...`
|
|
|
|
*/
|
|
|
|
|
|
|
|
var common = require('./common');
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-02 20:47:06 +03:00
|
|
|
function do_profile(subcmd, opts, args, callback) {
|
2015-08-25 23:13:54 +03:00
|
|
|
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) {
|
2015-09-01 19:00:45 +03:00
|
|
|
common.jsonStream(profs);
|
2015-08-25 23:13:54 +03:00
|
|
|
} else {
|
|
|
|
common.tabulate(profs, {
|
|
|
|
columns: 'curr,name,dcs,user,keyId',
|
|
|
|
sort: 'name,user',
|
|
|
|
validFields: 'curr,name,dcs,user,keyId'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
callback();
|
2015-09-01 19:00:45 +03:00
|
|
|
}
|
2015-08-25 23:13:54 +03:00
|
|
|
|
|
|
|
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}}'
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2015-09-01 19:00:45 +03:00
|
|
|
module.exports = do_profile;
|