Class: VagrantBootstrap::Commands::Bootstrap

Inherits:
Vagrant::Command::Base
  • Object
show all
Defined in:
lib/vagrant_bootstrap/commands/bootstrap.rb

Instance Method Summary collapse

Instance Method Details

#executeObject

Raises:

  • (Vagrant::Errors::CLIInvalidUsage)


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
# File 'lib/vagrant_bootstrap/commands/bootstrap.rb', line 9

def execute
  options = {}

  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant bootstrap <name>'
    o.separator ''

    o.on('-b', '--bridge BRIDGE',
      "Specify a bridge interface. Default is tap-#{VagrantBootstrap.whoami}") do |b|
      options[:bridge] = b
    end

    o.on '-t', '--template TEMPLATE', 'Supply your own TEMPLATE' do |t|
      options[:template] = t
    end
  end

  argv = parse_options(opts)
  return if !argv
  raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length < 1

  options[:template] ||= 'default.erb'
  options[:bridge]   ||= VagrantBootstrap::TapBridge.new.iface
  options[:name]       = "vagrant-#{VagrantBootstrap.whoami}-#{argv[0].strip}"

  VagrantBootstrap::Bootstrap.new(options).setup
end