Sha256: 8f395e8ce7cd0dd789fb393be83a72a7c4388215c1bd44afb8ddd0288e807356

Contents?: true

Size: 773 Bytes

Versions: 6

Compression:

Stored size: 773 Bytes

Contents

require 'optparse'

module Vagrant
  module Command
    class BoxAdd < Base
      def execute
        options = {}

        opts = OptionParser.new do |opts|
          opts.banner = "Usage: vagrant box add <name> <url>"
          opts.separator ""

          opts.on("-f", "--force", "Overwrite an existing box if it exists.") do |f|
            options[:force] = f
          end
        end

        # Parse the options
        argv = parse_options(opts)
        return if !argv

        # If we're force adding, then be sure to destroy any existing box if it
        # exists.
        if options[:force]
          existing = @env.boxes.find(argv[0])
          existing.destroy if existing
        end

        @env.boxes.add(argv[0], argv[1])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrantup-0.9.2 lib/vagrant/command/box_add.rb
vagrantup-0.9.1 lib/vagrant/command/box_add.rb
vagrantup-0.9.0 lib/vagrant/command/box_add.rb
vagrant-0.9.2 lib/vagrant/command/box_add.rb
vagrant-0.9.1 lib/vagrant/command/box_add.rb
vagrant-0.9.0 lib/vagrant/command/box_add.rb