Class: Veewee::Command::Vagrant::Templates

Inherits:
Vagrant::Command::Base
  • Object
show all
Defined in:
lib/veewee/command/vagrant/templates.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



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
# File 'lib/veewee/command/vagrant/templates.rb', line 7

def execute
  options = {}

  opts = OptionParser.new do |opts|
    opts.banner = "List the available templates"
    opts.separator ""
    opts.separator "Usage: vagrant basebox templates"
    opts.on("-d", "--debug", "enable debugging") do |d|
      options['debug'] = d
    end
  end

  # Parse the options
  argv = parse_options(opts)

  return if !argv

  begin
    venv=Veewee::Environment.new(options)
    venv.ui = @env.ui
    venv.ui.info("The following templates are available:",:prefix => false)
    venv.templates.each do |name,template|
      venv.ui.info("vagrant basebox define '<boxname>' '#{name}'",:prefix => false)
    end
  rescue Veewee::Error => ex
    venv.ui.error(ex,:prefix => false)
    exit -1
  end
end