Easy operations API `local` now echoes stdout/stderr

This commit is contained in:
Mitchell Hashimoto 2012-06-01 16:38:40 +02:00
parent ca6d49bc94
commit 903fd3acdc
1 changed files with 19 additions and 2 deletions

View File

@ -44,9 +44,26 @@ module Vagrant
# runtimes such as CRuby and JRuby.
#
# @param [String] command Command to run
def local(command)
# @param [Hash] options Additional options
def local(command, options=nil)
@logger.info("local: #{command}")
Vagrant::Util::Subprocess.execute(command)
block = nil
options = { :echo => true }.merge(options || {})
if options[:echo]
# If we're echoing data, then setup the block that sends the
# data to the UI.
block = Proc.new do |type, data|
if type == :stdout || type == :stderr
@vm.ui.info(data.to_s,
:prefix => false,
:new_line => false)
end
end
end
Vagrant::Util::Subprocess.execute(command, &block)
end
# Run a shell command within the VM. The command will run within a