From 835e1895bf53440e1773a8942715b46511916355 Mon Sep 17 00:00:00 2001 From: Dave Eddy Date: Wed, 26 Aug 2015 16:15:31 -0400 Subject: [PATCH] output state changes with "wait" --- lib/do_wait_instance.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/do_wait_instance.js b/lib/do_wait_instance.js index 946661f..befe759 100644 --- a/lib/do_wait_instance.js +++ b/lib/do_wait_instance.js @@ -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;