lib/vagrant/scp/commands/scp.rb in vagrant-scp-0.5.7 vs lib/vagrant/scp/commands/scp.rb in vagrant-scp-0.5.9

- old
+ new

@@ -1,5 +1,6 @@ +require 'pathname' module VagrantPlugins module Scp module Command @@ -49,11 +50,12 @@ private def parse_args opts = OptionParser.new do |o| o.banner = "Usage: vagrant scp <local_path> [vm_name]:<remote_path> \n" - o.banner += " vagrant scp [vm_name]:<remote_path> <local_path>" + o.banner += " vagrant scp [vm_name]:<remote_path> <local_path> \n" + o.banner += "Directories will be copied recursively." o.separator "" o.separator "Options:" o.separator "" end argv = parse_options(opts) @@ -75,20 +77,27 @@ def source_files format_file_path(@file_1) end def target_files - format_file_path(@file_2) + if target_location_specified? + format_file_path(@file_2) + else + Pathname.new(source_files).basename + end end def format_file_path(filepath) if filepath.include?(':') filepath.split(':').last.gsub("~", "/home/#{@ssh_info[:username]}") else filepath end end + def target_location_specified? + !@file_2.end_with?(':') + end end end end end