2016-02-09 22:23:55 +02: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 2016 Joyent, Inc.
|
|
|
|
*
|
|
|
|
* `triton instance tag list ...`
|
|
|
|
*/
|
|
|
|
|
2016-12-13 20:04:41 +02:00
|
|
|
var common = require('../../common');
|
2016-02-09 22:23:55 +02:00
|
|
|
var errors = require('../../errors');
|
|
|
|
|
|
|
|
function do_list(subcmd, opts, args, cb) {
|
|
|
|
var self = this;
|
|
|
|
if (opts.help) {
|
|
|
|
this.do_help('help', {}, [subcmd], cb);
|
|
|
|
return;
|
|
|
|
} else if (args.length !== 1) {
|
|
|
|
cb(new errors.UsageError('incorrect number of args'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-13 20:04:41 +02:00
|
|
|
common.cliSetupTritonApi({cli: this.top}, function onSetup(setupErr) {
|
|
|
|
if (setupErr) {
|
|
|
|
cb(setupErr);
|
2016-02-09 22:23:55 +02:00
|
|
|
}
|
2016-12-13 20:04:41 +02:00
|
|
|
self.top.tritonapi.listInstanceTags(
|
|
|
|
{id: args[0]}, function (err, tags) {
|
|
|
|
if (err) {
|
|
|
|
cb(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (opts.json) {
|
|
|
|
console.log(JSON.stringify(tags));
|
|
|
|
} else {
|
|
|
|
console.log(JSON.stringify(tags, null, 4));
|
|
|
|
}
|
|
|
|
cb();
|
|
|
|
});
|
2016-02-09 22:23:55 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
do_list.options = [
|
|
|
|
{
|
|
|
|
names: ['help', 'h'],
|
|
|
|
type: 'bool',
|
|
|
|
help: 'Show this help.'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
names: ['json', 'j'],
|
|
|
|
type: 'bool',
|
|
|
|
help: 'JSON output.'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2016-06-09 00:13:16 +03:00
|
|
|
do_list.synopses = ['{{name}} {{cmd}} INST'];
|
|
|
|
|
2016-02-09 22:23:55 +02:00
|
|
|
do_list.help = [
|
|
|
|
'List instance tags.',
|
|
|
|
'',
|
2016-06-09 00:13:16 +03:00
|
|
|
'{{usage}}',
|
2016-02-09 22:23:55 +02:00
|
|
|
'',
|
|
|
|
'{{options}}',
|
2016-06-09 00:13:16 +03:00
|
|
|
'Where INST is an instance id, name, or shortid.',
|
2016-02-09 22:23:55 +02:00
|
|
|
'',
|
|
|
|
'Note: Currently this dumps prettified JSON by default. That might change',
|
|
|
|
'in the future. Use "-j" to explicitly get JSON output.'
|
|
|
|
].join('\n');
|
|
|
|
|
|
|
|
do_list.aliases = ['ls'];
|
|
|
|
|
2016-03-09 19:19:44 +02:00
|
|
|
do_list.completionArgtypes = ['tritoninstance', 'none'];
|
|
|
|
|
2016-02-09 22:23:55 +02:00
|
|
|
module.exports = do_list;
|