diff --git a/lib/do_account.js b/lib/do_account/do_get.js similarity index 81% rename from lib/do_account.js rename to lib/do_account/do_get.js index 402a647..d9079d5 100644 --- a/lib/do_account.js +++ b/lib/do_account/do_get.js @@ -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; diff --git a/lib/do_account/index.js b/lib/do_account/index.js new file mode 100644 index 0000000..e70a53f --- /dev/null +++ b/lib/do_account/index.js @@ -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;