Class: Vagrant::Command::Package

Inherits:
Base
  • Object
show all
Defined in:
lib/vagrant/command/package.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Vagrant::Command::Base

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
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
# File 'lib/vagrant/command/package.rb', line 6

def execute
  options = {}

  opts = OptionParser.new do |opts|
    opts.banner = "Usage: vagrant package [vm-name] [--base name] [--output name.box]"
    opts.separator "                       [--include one,two,three] [--vagrantfile file]"

    opts.separator ""

    opts.on("--base NAME", "Name of a VM in virtualbox to package as a base box") do |b|
      options[:base] = b
    end

    opts.on("--output NAME", "Name of the file to output") do |o|
      options[:output] = o
    end

    opts.on("--include x,y,z", Array, "Additional files to package with the box.") do |i|
      options[:include] = i
    end

    opts.on("--vagrantfile file", "Vagrantfile to package with the box.") do |v|
      options[:vagrantfile] = v
    end
  end

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

  @logger.debug("package options: #{options.inspect}")
  if options[:base]
    package_base(options)
  else
    package_target(argv[0], options)
  end
end