From 1a7b78e00efb12cdfacca28f47ea5748710c939a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 25 Jan 2014 13:17:29 -0800 Subject: [PATCH] core: UI supports not echoing --- lib/vagrant/ui.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index 3654c83f8..2677d3238 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -1,4 +1,5 @@ require "delegate" +require "io/console" require "thread" require "log4r" @@ -123,17 +124,24 @@ module Vagrant # Setup the options so that the new line is suppressed opts ||= {} + opts[:echo] = true if !opts.has_key?(:echo) opts[:new_line] = false if !opts.has_key?(:new_line) opts[:prefix] = false if !opts.has_key?(:prefix) # Output the data say(:info, message, opts) + input = nil + if opts[:echo] + input = $stdin.gets + else + input = $stdin.noecho(&:gets) + end + # Get the results and chomp off the newline. We do a logical OR # here because `gets` can return a nil, for example in the case # that ctrl-D is pressed on the input. - input = $stdin.gets || "" - input.chomp + (input || "").chomp end # This is used to output progress reports to the UI.