Sha256: f32c881f4c130cea960d6bdbde336234bd3d591e4b0b3e548d336ee5450ba01a

Contents?: true

Size: 1.46 KB

Versions: 12

Compression:

Stored size: 1.46 KB

Contents

require 'optparse'

module VagrantPlugins
  module CommandBox
    module Command
      class Add < Vagrant.plugin("2", :command)
        def execute
          options = {}

          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant box add <name> <url> [--provider provider] [-h]"
            o.separator ""

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

            o.on("--insecure", "If set, SSL certs will not be validated.") do |i|
              options[:insecure] = i
            end

            o.on("--provider provider", String,
                 "The provider that backs the box.") do |p|
              options[:provider] = p
            end
          end

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

          # Get the provider if one was set
          provider = nil
          provider = options[:provider].to_sym if options[:provider]

          @env.action_runner.run(Vagrant::Action.action_box_add, {
            :box_name     => argv[0],
            :box_provider => provider,
            :box_url      => argv[1],
            :box_force    => options[:force],
            :box_download_insecure => options[:insecure],
          })

          # Success, exit status 0
          0
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/plugins/commands/box/command/add.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/plugins/commands/box/command/add.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/plugins/commands/box/command/add.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/plugins/commands/box/command/add.rb
tnargav-1.3.6 plugins/commands/box/command/add.rb
tnargav-1.3.3 plugins/commands/box/command/add.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/commands/box/command/add.rb
tnargav-1.2.3 plugins/commands/box/command/add.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/commands/box/command/add.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/commands/box/command/add.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/commands/box/command/add.rb
tnargav-1.2.2 plugins/commands/box/command/add.rb