Class: VagrantPlugins::SyncedFolderRSyncPull::Command

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Action::Builtin::MixinSyncedFolders
Defined in:
lib/vagrant-rsync-pull/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



13
14
15
# File 'lib/vagrant-rsync-pull/command.rb', line 13

def self.synopsis
  "rsyncs guest files to host"
end

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vagrant-rsync-pull/command.rb', line 17

def execute
  opts = OptionParser.new do |o|
    o.banner = "Usage: vagrant rsync-pull [vm-name]"
    o.separator ""
  end

  argv = parse_options(opts)
  return if !argv

  error = false
  with_target_vms do |machine|
    if !machine.communicate.ready?
      machine.ui.error(I18n.t("vagrant.rsync_communicator_not_ready"))
      error = true
      next
    end

    folders = synced_folders(machine)[:rsync_pull]
    next if !folders || folders.empty?

    folders.each do |id, folder_opts|
      RsyncPullHelper.rsync_single(machine, folder_opts)
    end
  end

  return error ? 1 : 0
end