diff --git a/lib/cli.js b/lib/cli.js index 9abb086..a29c30f 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -289,7 +289,8 @@ CLI.prototype.do_instance_audit = require('./do_instance_audit'); CLI.prototype.do_stop_instance = require('./do_startstop_instance')('stop'); CLI.prototype.do_start_instance = require('./do_startstop_instance')('start'); CLI.prototype.do_reboot_instance = require('./do_startstop_instance')('reboot'); -CLI.prototype.do_delete_instance = require('./do_startstop_instance')('delete'); +CLI.prototype.do_delete_instance = + require('./do_startstop_instance')({action: 'delete', aliases: ['rm']}); CLI.prototype.do_wait_instance = require('./do_wait_instance'); CLI.prototype.do_ssh = require('./do_ssh'); diff --git a/lib/do_startstop_instance.js b/lib/do_startstop_instance.js index e844c85..7e42fa4 100644 --- a/lib/do_startstop_instance.js +++ b/lib/do_startstop_instance.js @@ -22,15 +22,26 @@ function perror(err) { console.error('error: %s', err.message); } -function do_startstop_instance(action) { +function do_startstop_instance(opts) { + if (typeof (opts) === 'string') + opts = {action: opts}; + assert.object(opts, 'opts'); + assert.string(opts.action, 'opts.action'); + assert.optionalArrayOfString(opts.aliases, 'opts.aliases'); + var action = opts.action; + assert.ok(['start', 'stop', 'reboot', 'delete'].indexOf(action) >= 0, 'invalid action'); - function _do_startstop_instance(subcmd, opts, args, callback) { - return _do_instance.call(this, action, subcmd, opts, args, callback); + function _do_startstop_instance(subcmd, _opts, args, callback) { + return _do_instance.call(this, action, subcmd, _opts, args, callback); } - _do_startstop_instance.aliases = [action]; + var aliases = [action]; + if (opts.aliases) + aliases = aliases.concat(opts.aliases); + _do_startstop_instance.aliases = aliases; + _do_startstop_instance.help = [ f('%s a single instance.', common.capitalize(action)), f(''),