Sha256: 74d19b27221340a111f1ef0cc716023e1afb63f7d30372c170d9a73264b9ff77

Contents?: true

Size: 1.51 KB

Versions: 18

Compression:

Stored size: 1.51 KB

Contents

require 'optparse'

module Veewee
  module Command
    module Vagrant
      class Define < ::Vagrant::Command::Base
        def execute
          options = {}

          opts = OptionParser.new do |opts|
            opts.banner = "Define a new basebox based on a template"
            opts.separator ""
            opts.separator "Usage: vagrant basebox define <boxname> <template>"

            opts.on("-d", "--debug", "enable debugging") do |d|
              options['debug'] = d
            end

            opts.on("-f", "--force", "force overwrite") do |f|
              options['force'] = f
            end

          end

          # Parse the options
          argv = parse_options(opts)
          return if !argv
          raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2

          begin
            venv=Veewee::Environment.new(options)
            venv.ui=@env.ui
            definition_name=argv[0]
            template_name=argv[1]
            venv.definitions.define(definition_name,template_name,options)
            venv.ui.info "The basebox '#{definition_name}' has been successfully created from the template '#{template_name}'"
            venv.ui.info "You can now edit the definition files stored in definitions/#{definition_name} or build the box with:"
            venv.ui.info "vagrant basebox build '#{definition_name}'"
          rescue Veewee::Error => ex
            venv.ui.error(ex,:prefix => false)
            exit -1
          end

        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
veewee-0.5.0.alpha4 lib/veewee/command/vagrant/define.rb
veewee-0.5.0.alpha3 lib/veewee/command/vagrant/define.rb
veewee-0.5.0.alpha2 lib/veewee/command/vagrant/define.rb
veewee-0.5.0.alpha1 lib/veewee/command/vagrant/define.rb
veewee-0.4.5.1 lib/veewee/command/vagrant/define.rb
veewee-0.4.5 lib/veewee/command/vagrant/define.rb
veewee-0.4.5.pre1 lib/veewee/command/vagrant/define.rb
veewee-0.4.4 lib/veewee/command/vagrant/define.rb
veewee-0.4.3 lib/veewee/command/vagrant/define.rb
veewee-0.4.2 lib/veewee/command/vagrant/define.rb
veewee-0.4.1 lib/veewee/command/vagrant/define.rb
veewee-0.4.0 lib/veewee/command/vagrant/define.rb
veewee-0.3.12 lib/veewee/command/vagrant/define.rb
veewee-0.3.11 lib/veewee/command/vagrant/define.rb
veewee-0.3.10 lib/veewee/command/vagrant/define.rb
veewee-0.3.9 lib/veewee/command/vagrant/define.rb
veewee-atlassian-0.3.11 lib/veewee/command/vagrant/define.rb
veewee-0.3.7 lib/veewee/command/vagrant/define.rb