Sha256: 114c011375f3b1743e30d6bdf00293fdd11fbb88d3cb5413acda9838abd88efc

Contents?: true

Size: 1.96 KB

Versions: 56

Compression:

Stored size: 1.96 KB

Contents

require 'optparse'

module VagrantPlugins
  module CommandBox
    module Command
      class Remove < Vagrant.plugin("2", :command)
        def execute
          options = {}
          options[:force] = false

          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant box remove <name>"
            o.separator ""
            o.separator "Options:"
            o.separator ""

            o.on("-f", "--force", "Remove without confirmation.") do |f|
              options[:force] = f
            end

            o.on("--provider PROVIDER", String,
                 "The specific provider type for the box to remove") do |p|
              options[:provider] = p
            end

            o.on("--box-version VERSION", String,
                 "The specific version of the box to remove") do |v|
              options[:version] = v
            end

            o.on("--all", "Remove all available versions of the box") do |a|
              options[:all] = a
            end
          end

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

          if argv.length == 2
            # @deprecated
            @env.ui.warn("WARNING: The second argument to `vagrant box remove`")
            @env.ui.warn("is deprecated. Please use the --provider flag. This")
            @env.ui.warn("feature will stop working in the next version.")
            options[:provider] = argv[1]
          end

          @env.action_runner.run(Vagrant::Action.action_box_remove, {
            box_name:     argv[0],
            box_provider: options[:provider],
            box_version:  options[:version],
            force_confirm_box_remove: options[:force],
            box_remove_all_versions: options[:all],
          })

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

Version data entries

56 entries across 52 versions & 6 rubygems

Version Path
vagrant-unbundled-1.9.8.1 plugins/commands/box/command/remove.rb
vagrant-unbundled-1.9.7.1 plugins/commands/box/command/remove.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/box/command/remove.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/box/command/remove.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/box/command/remove.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/box/command/remove.rb
vagrant-unbundled-1.9.5.1 plugins/commands/box/command/remove.rb
vagrant-unbundled-1.9.1.1 plugins/commands/box/command/remove.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/box/command/remove.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/box/command/remove.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/box/command/remove.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/box/command/remove.rb
vagrant-unbundled-1.8.5.2 plugins/commands/box/command/remove.rb
vagrant-unbundled-1.8.5.1 plugins/commands/box/command/remove.rb
vagrant-unbundled-1.8.4.2 plugins/commands/box/command/remove.rb
vagrant-unbundled-1.8.4.1 plugins/commands/box/command/remove.rb