Display default on expunge command questions. Prompt user on invalid input.
This commit is contained in:
parent
159fca9d13
commit
4bbd43c73f
|
@ -17,11 +17,26 @@ module VagrantPlugins
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
if !env[:force]
|
if !env[:force]
|
||||||
result = env[:ui].ask(
|
|
||||||
I18n.t("vagrant.commands.plugin.expunge_confirm") +
|
result = nil
|
||||||
" [Y/N]:"
|
attempts = 0
|
||||||
)
|
while attempts < 5 && result.nil?
|
||||||
if result.to_s.downcase.strip != 'y'
|
attempts += 1
|
||||||
|
result = env[:ui].ask(
|
||||||
|
I18n.t("vagrant.commands.plugin.expunge_confirm") +
|
||||||
|
" [N]: "
|
||||||
|
)
|
||||||
|
result = result.to_s.downcase.strip
|
||||||
|
result = "n" if result.empty?
|
||||||
|
if !["y", "yes", "n", "no"].include?(result)
|
||||||
|
result = nil
|
||||||
|
env[:ui].error("Please answer Y or N")
|
||||||
|
else
|
||||||
|
result = result[0,1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if result != 'y'
|
||||||
abort_action = true
|
abort_action = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,11 +29,24 @@ module VagrantPlugins
|
||||||
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
|
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
|
||||||
|
|
||||||
if !options[:reinstall] && !options[:force] && !plugins.empty?
|
if !options[:reinstall] && !options[:force] && !plugins.empty?
|
||||||
result = @env.ui.ask(
|
result = nil
|
||||||
I18n.t("vagrant.commands.plugin.expunge_request_reinstall") +
|
attempts = 0
|
||||||
" [Y/N]:"
|
while attempts < 5 && result.nil?
|
||||||
)
|
attempts += 1
|
||||||
options[:reinstall] = result.to_s.downcase.strip == "y"
|
result = @env.ui.ask(
|
||||||
|
I18n.t("vagrant.commands.plugin.expunge_request_reinstall") +
|
||||||
|
" [N]: "
|
||||||
|
)
|
||||||
|
result = result.to_s.downcase.strip
|
||||||
|
result = "n" if result.empty?
|
||||||
|
if !["y", "yes", "n", "no"].include?(result)
|
||||||
|
result = nil
|
||||||
|
@env.ui.error("Please answer Y or N")
|
||||||
|
else
|
||||||
|
result = result[0,1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
options[:reinstall] = result == "y"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove all installed user plugins
|
# Remove all installed user plugins
|
||||||
|
|
Loading…
Reference in New Issue