Sha256: d79df74257c68125827c9d91fc8a4f99c526cacda1f32e46b6a1fec1b260d591

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'optparse'

module VagrantPlugins
  module Rsync
    class Command < Vagrant.plugin("2", :command)
      def execute
        options = {}
        options[:install_rsync] = true
        options[:verbose] = false

        opts = OptionParser.new do |o|
          o.banner = "DEPRECATED!! Usage: vagrant rsync [vm-name]"

          o.on("-n", "--no-install", "Do not attempt to install rysnc if not found") do |ni|
            options[:install_rsync] = !ni
          end

          o.on('-v', '--verbose', "Run verbosely") do |v|
            options[:verbose] = v
          end

          o.on( '-h', '--help', 'Display this screen' ) do
            puts opts
            exit
          end
        end

        # Parse the options
        argv = parse_options(opts)
        return if !argv

        with_target_vms(argv) do |vm|
          raise Vagrant::Errors::VMNotCreatedError if vm.state.id == :not_created
          raise Vagrant::Errors::VMInaccessible if vm.state.id == :inaccessible
        end

        with_target_vms(argv) do |machine|
          if options[:install_rsync]
            @env.ui.info I18n.t('vagrant_rsync.ensure_rsync')
            machine.guest.capability(:ensure_rsync, @env)
          end

          @env.ui.info I18n.t('vagrant_rsync.rsync_folders')
          machine.guest.capability(:rsync_folders)
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-rsync-0.2.5 lib/vagrant-rsync/command.rb