Class: VagrantPlugins::Unify::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-unify/command-pull.rb,
lib/vagrant-unify/command-push.rb,
lib/vagrant-unify/command-sync.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



10
11
12
# File 'lib/vagrant-unify/command-pull.rb', line 10

def self.synopsis
  I18n.t("vagrant_unify.pull.synopsis")
end

Instance Method Details

#executeObject



14
15
16
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
44
# File 'lib/vagrant-unify/command-pull.rb', line 14

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

  argv = parse_options(params)
  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

    machine.config.unify.folders.each { |folder|
      local_path  = folder.fetch(0, nil)
      remote_path = folder.fetch(1, nil)
      opts        = folder.fetch(2, {})

      raise Vagrant::Errors::UnifyConfigError, :err => I18n.t("vagrant_unify.config.local_path_required") if local_path.nil? or local_path.empty?
      raise Vagrant::Errors::UnifyConfigError, :err => I18n.t("vagrant_unify.config.remote_path_required") if remote_path.nil? or remote_path.empty?

      UnifyHelper.rsync_single(:pull, machine, local_path, remote_path, opts)
    }
  end

  return error ? 1 : 0
end