delete "rm" alias, fixes #44

This commit is contained in:
Dave Eddy 2015-10-14 16:15:45 -04:00
parent f1e90cdab8
commit 08527b433c
2 changed files with 17 additions and 5 deletions

View File

@ -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_stop_instance = require('./do_startstop_instance')('stop');
CLI.prototype.do_start_instance = require('./do_startstop_instance')('start'); CLI.prototype.do_start_instance = require('./do_startstop_instance')('start');
CLI.prototype.do_reboot_instance = require('./do_startstop_instance')('reboot'); 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_wait_instance = require('./do_wait_instance');
CLI.prototype.do_ssh = require('./do_ssh'); CLI.prototype.do_ssh = require('./do_ssh');

View File

@ -22,15 +22,26 @@ function perror(err) {
console.error('error: %s', err.message); 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, assert.ok(['start', 'stop', 'reboot', 'delete'].indexOf(action) >= 0,
'invalid action'); 'invalid action');
function _do_startstop_instance(subcmd, opts, args, callback) { function _do_startstop_instance(subcmd, _opts, args, callback) {
return _do_instance.call(this, action, 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 = [ _do_startstop_instance.help = [
f('%s a single instance.', common.capitalize(action)), f('%s a single instance.', common.capitalize(action)),
f(''), f(''),