Class: VagrantPlugins::Export::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-export/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



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

def self.synopsis
  'exports a box file with additional actions taken'
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
45
46
47
48
# File 'lib/vagrant-export/command.rb', line 14

def execute
  options = {}
  options[:fast] = false
  options[:bare] = false

  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant export [switches]'
    o.separator ''

    o.on('-f', '--fast', 'Do not perform cleanups.') do |f|
      options[:fast] = f
    end

    o.on('-b', '--bare', 'Do not include additional files.') do |b|
      options[:bare] = b
    end
  end

  argv = parse_options(opts)
  return 1 unless argv

  require_relative 'exporter'

  with_target_vms argv, reverse: true do |machine|
    ex = Exporter.new(@env, @logger, machine)

    if File.file?(ex.target_box)
      require_relative 'error'
      raise BoxAlreadyExists
    end

    ex.handle(options[:fast], options[:bare])
  end
  0
end