From 3f9a2814c723ccbbbdc7e963c1f1c0b388ef4609 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Aug 2011 22:17:37 -0700 Subject: [PATCH] Clean up some of the UI output --- lib/vagrant/action/vm/import.rb | 5 +++++ lib/vagrant/ui.rb | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/action/vm/import.rb b/lib/vagrant/action/vm/import.rb index 7ee053780..867eb99c1 100644 --- a/lib/vagrant/action/vm/import.rb +++ b/lib/vagrant/action/vm/import.rb @@ -11,9 +11,14 @@ module Vagrant # Import the virtual machine env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file.to_s) do |progress| + env.ui.clear_line env.ui.report_progress(progress.percent, 100, false) end + # Clear the line one last time since the progress meter doesn't disappear + # immediately. + env.ui.clear_line + # Flag as erroneous and return if import failed raise Errors::VMImportFailure if !env["vm"].vm diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index b62b0089e..7d0a932a8 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -34,7 +34,7 @@ module Vagrant class_eval <<-CODE def #{method}(message, opts=nil) super(message) - @shell.say("\#{line_reset}\#{format_message(message, opts)}", #{color.inspect}) + @shell.say("\#{format_message(message, opts)}", #{color.inspect}) end CODE end @@ -53,11 +53,14 @@ module Vagrant percent = (progress.to_f / total.to_f) * 100 line = "Progress: #{percent.to_i}%" line << " (#{progress} / #{total})" if show_parts - line = "#{line_reset}#{line}" @shell.say(line, nil, false) end + def clear_line + @shell.say(line_reset, nil, false) + end + protected def format_message(message, opts=nil)