vagrant box remove doesn't need provider if box only has one [GH-1032]

This commit is contained in:
Mitchell Hashimoto 2013-07-10 19:57:53 -07:00
parent f38b6801f9
commit 3840e07adb
3 changed files with 34 additions and 1 deletions

View File

@ -8,6 +8,8 @@ FEATURES:
IMPROVEMENTS:
- `vagrant box remove` works with only the name of the box if that
box exists only backed by one provider. [GH-1032]
- `vagrant destroy` returns exit status 1 if any of the confirmations
are declined. [GH-923]

View File

@ -12,7 +12,27 @@ module VagrantPlugins
# Parse the options
argv = parse_options(opts)
return if !argv
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 1
if !argv[1]
# Try to automatically determine the provider.
providers = []
@env.boxes.all.each do |name, provider|
if name == argv[0]
providers << provider
end
end
if providers.length > 1
@env.ui.error(
I18n.t("vagrant.commands.box.remove_must_specify_provider",
name: args[0],
providers: providers.join(", ")))
return 1
end
argv[1] = providers[0] || ""
end
b = nil
begin

View File

@ -656,6 +656,17 @@ en:
vm_not_created: "VM not created. Moving on..."
vm_not_running: "VM is not currently running. Please bring it up to run this command."
box:
remove_must_specify_provider: |-
Multiple providers were found for the box '%{name}'. Please specify
the specific provider for the box you want to remove. The list of
providers backing this box is:
'%{providers}'
To remove the box for a specific provider, run the following command,
filling in PROVIDER with one of the providers above:
vagrant box remove '%{name}' PROVIDER
no_installed_boxes: "There are no installed boxes! Use `vagrant box add` to add some."
removing: |-
Removing box '%{name}' with provider '%{provider}'...