Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 80 lines (58 sloc) 2.031 kb
1 2 3 4 5 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
#!/usr/bin/env ruby

require 'rubygems'
require 'thor'
require 'bundler'
require 'virtualbox'
require 'veewee'


#Setup some base variables to use
veewee_dir= File.expand_path(File.join(File.dirname(__FILE__),".."))
definition_dir= File.expand_path(File.join(".", "definitions"))
lib_dir= File.expand_path(File.join(veewee_dir, "lib"))
box_dir= File.expand_path(File.join(veewee_dir, "boxes"))
template_dir=File.expand_path(File.join(veewee_dir, "templates"))

#vbox_dir=File.expand_path(File.join(veewee_dir, "tmp"))
tmp_dir=File.expand_path(File.join(veewee_dir, "tmp"))

iso_dir=File.expand_path(File.join(veewee_dir, "iso"))

#needs to be moved to the config files to be allowed override
#ENV['VBOX_USER_HOME']=vbox_dir

#Load Veewee::Session libraries
Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f|
  require f }

#Initialize
Veewee::Session.setenv({:veewee_dir => veewee_dir, :definition_dir => definition_dir,
   :template_dir => template_dir, :iso_dir => iso_dir, :box_dir => box_dir, :tmp_dir => tmp_dir})


   
class VeeweeCLI < Thor
  
  desc "init [NAME] [TEMPLATE]", "initializes a box from a template"
  method_options :force => :boolean
  def init(boxname=nil, template=nil)
    if (boxname.nil?)
      puts "please provide a boxname"
      exit
    end
    
    puts "Init a new box #{boxname}, starting from template #{template}"
   Veewee::Session.define(boxname,template)
  
  end

  desc "templates", "list the template available"
  def templates
    Veewee::Session.list_templates
  end
  
  desc "build [NAME]", "build the box defined"
  method_options :force => :boolean
  def build(boxname)
    puts "Building box #{boxname}"
Veewee::Session.build(boxname)
  end

  desc "export [NAME]", "export the box"
  method_options :force => :boolean
  def export(boxname)
      if (!boxname.nil?)
        Veewee::Session.export_box(boxname)
      end
  end
  
end



version=VirtualBox.version
if (version.match(/^4./))
    VeeweeCLI.start
else
    puts "veewee only supports VirtualBox 4.x"
end
Something went wrong with that request. Please try again.