UI errors if a TTY is required and not given
This commit is contained in:
parent
700938b668
commit
95b3e9f82f
|
@ -323,6 +323,11 @@ module Vagrant
|
||||||
error_key(:ssh_unavailable_windows)
|
error_key(:ssh_unavailable_windows)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class UIExpectsTTY < VagrantError
|
||||||
|
status_code(73)
|
||||||
|
error_key(:ui_expects_tty)
|
||||||
|
end
|
||||||
|
|
||||||
class VagrantInterrupt < VagrantError
|
class VagrantInterrupt < VagrantError
|
||||||
status_code(40)
|
status_code(40)
|
||||||
error_key(:interrupted)
|
error_key(:interrupted)
|
||||||
|
|
|
@ -51,6 +51,9 @@ module Vagrant
|
||||||
def ask(message, opts=nil)
|
def ask(message, opts=nil)
|
||||||
super(message)
|
super(message)
|
||||||
|
|
||||||
|
# We can't ask questions when the output isn't a TTY.
|
||||||
|
raise Errors::UIExpectsTTY if !$stdin.tty?
|
||||||
|
|
||||||
# Setup the options so that the new line is suppressed
|
# Setup the options so that the new line is suppressed
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
opts[:new_line] = false if !opts.has_key?(:new_line)
|
opts[:new_line] = false if !opts.has_key?(:new_line)
|
||||||
|
@ -60,7 +63,7 @@ module Vagrant
|
||||||
say(:info, message, opts)
|
say(:info, message, opts)
|
||||||
|
|
||||||
# Get the results and chomp off the newline
|
# Get the results and chomp off the newline
|
||||||
STDIN.gets.chomp
|
$stdin.gets.chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is used to output progress reports to the UI.
|
# This is used to output progress reports to the UI.
|
||||||
|
|
|
@ -141,6 +141,11 @@ en:
|
||||||
Port: %{port}
|
Port: %{port}
|
||||||
Username: %{username}
|
Username: %{username}
|
||||||
Private key: %{key_path}
|
Private key: %{key_path}
|
||||||
|
ui_expects_tty: |-
|
||||||
|
Vagrant is attempting to interface with the UI in a way that requires
|
||||||
|
a TTY. Most actions in Vagrant that require a TTY have configuration
|
||||||
|
switches to disable this requirement. Please do that or run Vagrant
|
||||||
|
with TTY.
|
||||||
vagrantfile_exists: |-
|
vagrantfile_exists: |-
|
||||||
`Vagrantfile` already exists in this directory. Remove it before
|
`Vagrantfile` already exists in this directory. Remove it before
|
||||||
running `vagrant init`.
|
running `vagrant init`.
|
||||||
|
|
Loading…
Reference in New Issue