output state changes with "wait"

This commit is contained in:
Dave Eddy 2015-08-26 16:15:31 -04:00
parent 255fff221b
commit 835e1895bf

View File

@ -16,8 +16,14 @@ function do_wait_instance(subcmd, opts, args, cb) {
return;
}
function log() {
if (!opts.quiet)
console.log.apply(console, arguments);
}
var ids = args[0].split(',');
var states = (args[1] || 'failed,running').split(',');
var done = 0;
var machines = {};
@ -37,6 +43,8 @@ function do_wait_instance(subcmd, opts, args, cb) {
}
if (states.indexOf(machine.state) >= 0) {
// machine in acceptable state already... skip it
log('%d/%d: %s already in acceptable state: %s',
++done, ids.length, id, machine.state);
} else {
machines[machine.id] = machine;
}
@ -67,6 +75,8 @@ function do_wait_instance(subcmd, opts, args, cb) {
cb(err);
return;
}
log('%d/%d: %s moved to state %s',
++done, ids.length, body.name, body.state);
if (--i === 0) {
cb();
}
@ -90,6 +100,11 @@ do_wait_instance.options = [
type: 'bool',
help: 'Show this help.'
},
{
names: ['quiet', 'q'],
type: 'bool',
help: 'Disable all output.'
},
];
module.exports = do_wait_instance;