Wrap all progress type outputs with rewriting to enable --no-tty
This commit is contained in:
parent
e6c387cdce
commit
39d7cd8997
@ -76,6 +76,9 @@ module Vagrant
|
||||
@logger.info("Machine: #{type} #{data.inspect}")
|
||||
end
|
||||
|
||||
# Yields self (UI)
|
||||
# Provides a way for selectively displaying or not displaying
|
||||
# updating content like download progress.
|
||||
def rewriting
|
||||
yield self
|
||||
end
|
||||
|
||||
@ -37,8 +37,10 @@ module Vagrant
|
||||
source_host = source_uri.host.to_s.split(".", 2).last
|
||||
location_host = location_uri.host.to_s.split(".", 2).last
|
||||
if !redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host)
|
||||
ui.clear_line
|
||||
ui.detail "Download redirected to host: #{location_uri.host}"
|
||||
ui.rewriting do |ui|
|
||||
ui.clear_line
|
||||
ui.detail "Download redirected to host: #{location_uri.host}"
|
||||
end
|
||||
end
|
||||
redirect_notify = true
|
||||
end
|
||||
|
||||
@ -25,8 +25,10 @@ module VagrantPlugins
|
||||
@env[:ui].info I18n.t("vagrant.actions.vm.export.exporting")
|
||||
export_tmp_dir = Vagrant::Util::Platform.wsl_to_windows_path(@env["export.temp_dir"])
|
||||
@env[:machine].provider.driver.export(export_tmp_dir) do |progress|
|
||||
@env[:ui].clear_line
|
||||
@env[:ui].report_progress(progress.percent, 100, false)
|
||||
@env[:ui].rewriting do |ui|
|
||||
ui.clear_line
|
||||
ui.report_progress(progress.percent, 100, false)
|
||||
end
|
||||
end
|
||||
|
||||
# Clear the line a final time so the next data can appear
|
||||
|
||||
@ -23,8 +23,10 @@ module VagrantPlugins
|
||||
def export
|
||||
@env[:ui].info I18n.t("vagrant.actions.vm.export.exporting")
|
||||
@env[:machine].provider.driver.export(ovf_path) do |progress|
|
||||
@env[:ui].clear_line
|
||||
@env[:ui].report_progress(progress.percent, 100, false)
|
||||
@env[:ui].rewriting do |ui|
|
||||
ui.clear_line
|
||||
ui.report_progress(progress.percent, 100, false)
|
||||
end
|
||||
end
|
||||
|
||||
# Clear the line a final time so the next data can appear
|
||||
|
||||
@ -19,8 +19,10 @@ module VagrantPlugins
|
||||
env[:ui].info I18n.t("vagrant.actions.vm.clone.creating")
|
||||
env[:machine].id = env[:machine].provider.driver.clonevm(
|
||||
env[:clone_id], env[:clone_snapshot]) do |progress|
|
||||
env[:ui].clear_line
|
||||
env[:ui].report_progress(progress, 100, false)
|
||||
env[:ui].rewriting do |ui|
|
||||
ui.clear_line
|
||||
ui.report_progress(progress, 100, false)
|
||||
end
|
||||
end
|
||||
|
||||
# Clear the line one last time since the progress meter doesn't
|
||||
@ -51,8 +53,10 @@ module VagrantPlugins
|
||||
# Import the virtual machine
|
||||
ovf_file = env[:machine].box.directory.join("box.ovf").to_s
|
||||
id = env[:machine].provider.driver.import(ovf_file) do |progress|
|
||||
env[:ui].clear_line
|
||||
env[:ui].report_progress(progress, 100, false)
|
||||
env[:ui].rewriting do |ui|
|
||||
ui.clear_line
|
||||
ui.report_progress(progress, 100, false)
|
||||
end
|
||||
end
|
||||
|
||||
# Set the machine ID
|
||||
|
||||
@ -55,8 +55,10 @@ module VagrantPlugins
|
||||
@logger.info("Creating base snapshot for master VM.")
|
||||
env[:machine].provider.driver.create_snapshot(
|
||||
env[:clone_id], name) do |progress|
|
||||
env[:ui].clear_line
|
||||
env[:ui].report_progress(progress, 100, false)
|
||||
env[:ui].rewriting do |ui|
|
||||
ui.clear_line
|
||||
ui.report_progress(progress, 100, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -12,8 +12,10 @@ module VagrantPlugins
|
||||
name: env[:snapshot_name]))
|
||||
env[:machine].provider.driver.delete_snapshot(
|
||||
env[:machine].id, env[:snapshot_name]) do |progress|
|
||||
env[:ui].clear_line
|
||||
env[:ui].report_progress(progress, 100, false)
|
||||
env[:ui].rewriting do |ui|
|
||||
ui.clear_line
|
||||
ui.report_progress(progress, 100, false)
|
||||
end
|
||||
end
|
||||
|
||||
# Clear the line one last time since the progress meter doesn't disappear
|
||||
|
||||
@ -12,8 +12,10 @@ module VagrantPlugins
|
||||
name: env[:snapshot_name]))
|
||||
env[:machine].provider.driver.restore_snapshot(
|
||||
env[:machine].id, env[:snapshot_name]) do |progress|
|
||||
env[:ui].clear_line
|
||||
env[:ui].report_progress(progress, 100, false)
|
||||
env[:ui].rewriting do |ui|
|
||||
ui.clear_line
|
||||
ui.report_progress(progress, 100, false)
|
||||
end
|
||||
end
|
||||
|
||||
# Clear the line one last time since the progress meter doesn't disappear
|
||||
|
||||
@ -38,6 +38,7 @@ describe Vagrant::Util::Downloader do
|
||||
before do
|
||||
allow(ui).to receive(:clear_line)
|
||||
allow(ui).to receive(:detail)
|
||||
allow(ui).to receive(:rewriting).and_yield(ui)
|
||||
end
|
||||
|
||||
after do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user