core: UI supports not echoing
This commit is contained in:
parent
222ec288f2
commit
1a7b78e00e
|
@ -1,4 +1,5 @@
|
||||||
require "delegate"
|
require "delegate"
|
||||||
|
require "io/console"
|
||||||
require "thread"
|
require "thread"
|
||||||
|
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
@ -123,17 +124,24 @@ module Vagrant
|
||||||
|
|
||||||
# Setup the options so that the new line is suppressed
|
# Setup the options so that the new line is suppressed
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
|
opts[:echo] = true if !opts.has_key?(:echo)
|
||||||
opts[:new_line] = false if !opts.has_key?(:new_line)
|
opts[:new_line] = false if !opts.has_key?(:new_line)
|
||||||
opts[:prefix] = false if !opts.has_key?(:prefix)
|
opts[:prefix] = false if !opts.has_key?(:prefix)
|
||||||
|
|
||||||
# Output the data
|
# Output the data
|
||||||
say(:info, message, opts)
|
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
|
# 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
|
# here because `gets` can return a nil, for example in the case
|
||||||
# that ctrl-D is pressed on the input.
|
# that ctrl-D is pressed on the input.
|
||||||
input = $stdin.gets || ""
|
(input || "").chomp
|
||||||
input.chomp
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is used to output progress reports to the UI.
|
# This is used to output progress reports to the UI.
|
||||||
|
|
Loading…
Reference in New Issue