diff --git a/lib/vagrant/easy/command_api.rb b/lib/vagrant/easy/command_api.rb index b4a00045e..b29446aa2 100644 --- a/lib/vagrant/easy/command_api.rb +++ b/lib/vagrant/easy/command_api.rb @@ -1,6 +1,8 @@ require "delegate" require "optparse" +require "log4r" + require "vagrant/easy/operations" module Vagrant @@ -13,8 +15,9 @@ module Vagrant def initialize(vm, argv) super(Operations.new(vm)) - @argv = argv - @vm = vm + @logger = Log4r::Logger.new("vagrant::easy::command_api") + @argv = argv + @vm = vm end # Gets the value of an argument from the command line. Many arguments @@ -22,6 +25,8 @@ module Vagrant # # @return [String] def arg(*names) + @logger.info("reading args: #{names.inspect}") + # Mangle the names a bit to add "=VALUE" to every flag. names = names.map do |name| "#{name}=VALUE" diff --git a/lib/vagrant/easy/operations.rb b/lib/vagrant/easy/operations.rb index 584ec2588..581403fb1 100644 --- a/lib/vagrant/easy/operations.rb +++ b/lib/vagrant/easy/operations.rb @@ -58,18 +58,22 @@ module Vagrant # puts "Output was #{output.stdout}" # # @param [String] command Command to run - def run(command) + # @param [Hash] options Additional options + def run(command, options=nil) @logger.info("run: #{command}") - remote_command(:execute, command) + options = { :echo => true }.merge(options || {}) + remote_command(:execute, command, options) end # Same as {run} except runs the command with superuser privileges # via `sudo`. # # @param [String] command Command - def sudo(command) + # @param [Hash] options Additional options + def sudo(command, options=nil) @logger.info("sudo: #{command}") - remote_command(:sudo, command) + options = { :echo => true }.merge(options || {}) + remote_command(:sudo, command, options) end # Uploads a file to the virtual machine. @@ -105,7 +109,7 @@ module Vagrant protected # Runs a command on the remote host. - def remote_command(type, command) + def remote_command(type, command, options) # If the VM is not running, then we can't run SSH commands... raise Errors::VMNotRunningError if @vm.state != :running @@ -120,6 +124,13 @@ module Vagrant elsif type == :stderr result.stderr += data end + + # If we're echoing data, then echo it! + if options[:echo] + @vm.ui.info(data.to_s, + :prefix => false, + :new_line => false) + end end # Return the result