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. * 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) { if (opts.help) {
this.do_help('help', {}, [subcmd], callback); this.do_help('help', {}, [subcmd], callback);
return; return;
@ -21,7 +21,7 @@ function do_account(subcmd, opts, args, callback) {
return; return;
} }
this.tritonapi.cloudapi.getAccount(function (err, account) { this.top.tritonapi.cloudapi.getAccount(function (err, account) {
if (err) { if (err) {
callback(err); callback(err);
return; return;
@ -46,7 +46,7 @@ function do_account(subcmd, opts, args, callback) {
}); });
} }
do_account.options = [ do_get.options = [
{ {
names: ['help', 'h'], names: ['help', 'h'],
type: 'bool', type: 'bool',
@ -58,15 +58,13 @@ do_account.options = [
help: 'JSON output.' help: 'JSON output.'
} }
]; ];
do_account.help = ( do_get.help = (
'Show account information\n' 'Show account information\n'
+ '\n' + '\n'
+ 'Usage:\n' + 'Usage:\n'
+ ' {{name}} account\n' + ' {{name}} get\n'
+ '\n' + '\n'
+ '{{options}}' + '{{options}}'
); );
do_account.aliases = ['whoami']; module.exports = do_get;
module.exports = do_account;

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;