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