lib/veewee/command.rb in veewee-0.0.2 vs lib/veewee/command.rb in veewee-0.1.0a

- old
+ new

@@ -1,66 +1,63 @@ require 'veewee/session' -#Load Veewee::Session libraries -lib_dir= File.expand_path(File.join(File.dirname(__FILE__),"..","..", "lib")) -Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f| require f } - #Setup some base variables to use -template_dir=File.expand_path(File.join(lib_dir,"..", "templates")) +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")) -veewee_dir="." -definition_dir= File.expand_path(File.join(veewee_dir, "definitions")) +#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")) -box_dir=File.expand_path(File.join(veewee_dir, "boxes")) +#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}) -module Veewee -class Command < Vagrant::Command::GroupBase - register "basebox","Commands to manage baseboxes" - desc "templates", "List the currently available box templates" - def templates - Veewee::Session.list_templates - end +module Vagrant + module Command + class BoxCommand < Vagrant::Command::GroupBase + # Do not register anymore, as this registration is already done in Vagrant core + # Since Ruby classes are 'open', we are just adding subcommands to the 'box' command - desc "define BOXNAME TEMPLATE", "Define a new box starting from a template" - method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition" - def define(boxname, template) - Veewee::Session.define(boxname,template,options) - end + desc "templates", "List the currently available box templates" + def templates + Veewee::Session.list_templates + end - desc "build BOXNAME", "Build the box BOXNAME" - method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the basebox" - def build(boxname) - Veewee::Session.build(boxname,options) - end + desc "init BOXNAME TEMPLATE", "Define a new box starting from a template" + def init(boxname, template) + puts "Init a new box #{boxname}, starting from template #{template}" + Veewee::Session.define(boxname,template) + end - desc "ostypes", "List the available Operating System types" - def ostypes - Veewee::Session.list_ostypes - end - - desc "destroy BOXNAME", "Destroy the virtualmachine of a basebox" - def destroy(boxname) - puts Veewee::Session.destroy_vm(boxname) - end - - desc "list", "Lists all defined boxes" - def list - Veewee::Session.list_definitions - end - - desc "export [NAME]", "export the box" - method_options :force => :boolean - def export(boxname) - if (!boxname.nil?) - Veewee::Session.export_box(boxname) + desc "build BOXNAME", "Build the box BOXNAME" + def build(boxname) + puts "Building box #{boxname}" + Veewee::Session.build(boxname) end + + desc "ostypes", "List the available Operating System types" + def ostypes + puts "Operating System types:" + Veewee::Session.list_ostypes + end + + desc "clean", "Clean all unfinished builds" + def clean + puts "Cleaning all unfinished builds" + end + + end end - end - -end \ No newline at end of file