/*
* 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.
*
* `triton keys ...`
var common = require('./common');
function do_keys(subcmd, opts, args, callback) {
if (opts.help) {
this.do_help('help', {}, [subcmd], callback);
return;
} else if (args.length !== 0) {
callback(new Error('invalid args: ' + args));
}
this.tritonapi.cloudapi.listKeys(function (err, keys) {
if (err) {
callback(err);
if (opts.json) {
common.jsonStream(keys);
} else {
// pretty print
keys.forEach(function (key) {
console.log(key.key);
});
callback();
do_keys.options = [
{
names: ['help', 'h'],
type: 'bool',
help: 'Show this help.'
},
names: ['json', 'j'],
help: 'JSON output.'
];
do_keys.help = (
'Show account keys.\n'
+ '\n'
+ 'Usage:\n'
+ ' {{name}} keys\n'
+ '{{options}}'
);
module.exports = do_keys;