This repository has been archived on 2020-01-20. You can view files and clone it, but cannot push or open issues or pull requests.
node-spearhead/lib/do_instance.js

54 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-08-26 03:27:46 +03:00
/*
* Copyright 2015 Joyent Inc.
*
* `triton instance ...`
*/
var common = require('./common');
function do_instance(subcmd, opts, args, cb) {
2015-08-26 03:27:46 +03:00
if (opts.help) {
return this.do_help('help', {}, [subcmd], cb);
2015-08-26 03:27:46 +03:00
} else if (args.length !== 1) {
return cb(new Error('invalid args: ' + args));
2015-08-26 03:27:46 +03:00
}
this.triton.getInstance(args[0], function (err, inst) {
2015-08-26 03:27:46 +03:00
if (err) {
return cb(err);
2015-08-26 03:27:46 +03:00
}
if (opts.json) {
console.log(JSON.stringify(inst));
} else {
console.log(JSON.stringify(inst, null, 4));
}
cb();
});
2015-08-26 03:27:46 +03:00
}
do_instance.options = [
{
names: ['help', 'h'],
type: 'bool',
help: 'Show this help.'
},
{
names: ['json', 'j'],
type: 'bool',
help: 'JSON output.'
}
];
do_instance.help = (
'Show a single instance.\n'
+ '\n'
+ 'Usage:\n'
+ ' {{name}} instance <alias|id>\n'
+ '\n'
+ '{{options}}'
);
do_instance.aliases = ['inst'];
module.exports = do_instance;