clistyle: 'triton account ...'

This commit is contained in:
Trent Mick 2016-01-04 22:51:04 -08:00
parent 13b525cca7
commit 105b7bf9a4
2 changed files with 56 additions and 10 deletions

View File

@ -7,12 +7,12 @@
/*
* Copyright 2015 Joyent, Inc.
*
* `triton account ...`
* `triton account get ...`
*/
var common = require('./common');
var common = require('../common');
function do_account(subcmd, opts, args, callback) {
function do_get(subcmd, opts, args, callback) {
if (opts.help) {
this.do_help('help', {}, [subcmd], callback);
return;
@ -21,7 +21,7 @@ function do_account(subcmd, opts, args, callback) {
return;
}
this.tritonapi.cloudapi.getAccount(function (err, account) {
this.top.tritonapi.cloudapi.getAccount(function (err, account) {
if (err) {
callback(err);
return;
@ -46,7 +46,7 @@ function do_account(subcmd, opts, args, callback) {
});
}
do_account.options = [
do_get.options = [
{
names: ['help', 'h'],
type: 'bool',
@ -58,15 +58,13 @@ do_account.options = [
help: 'JSON output.'
}
];
do_account.help = (
do_get.help = (
'Show account information\n'
+ '\n'
+ 'Usage:\n'
+ ' {{name}} account\n'
+ ' {{name}} get\n'
+ '\n'
+ '{{options}}'
);
do_account.aliases = ['whoami'];
module.exports = do_account;
module.exports = do_get;

48
lib/do_account/index.js Normal file
View File

@ -0,0 +1,48 @@
/*
* 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 account ...`
*/
var Cmdln = require('cmdln').Cmdln;
var util = require('util');
// ---- CLI class
function AccountCLI(top) {
this.top = top;
Cmdln.call(this, {
name: top.name + ' account',
/* BEGIN JSSTYLED */
desc: [
'Get and update your Triton account.'
].join('\n'),
/* END JSSTYLED */
helpOpts: {
minHelpCol: 24 /* line up with option help */
},
helpSubcmds: [
'help',
'get'
]
});
}
util.inherits(AccountCLI, Cmdln);
AccountCLI.prototype.init = function init(opts, args, cb) {
this.log = this.top.log;
Cmdln.prototype.init.apply(this, arguments);
};
AccountCLI.prototype.do_get = require('./do_get');
module.exports = AccountCLI;