commands/box/remove: add --force flag

This commit is contained in:
Mitchell Hashimoto 2014-04-23 06:16:51 -07:00
parent 85f4a4d5ee
commit 5da77dee5c
2 changed files with 23 additions and 1 deletions

View File

@ -6,11 +6,17 @@ module VagrantPlugins
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.separator ""
o.on("-f", "--force", "Destroy without confirmation.") do |f|
options[:force] = f
end
o.on("--provider PROVIDER", String,
"The specific provider type for the box to remove") do |p|
@ -43,6 +49,7 @@ module VagrantPlugins
:box_name => argv[0],
:box_provider => options[:provider],
:box_version => options[:version],
:force_confirm_box_remove => options[:force],
})
# Success, exit status 0

View File

@ -34,11 +34,26 @@ describe VagrantPlugins::CommandBox::Command::Remove do
it "invokes the action runner" do
expect(action_runner).to receive(:run).with { |action, opts|
expect(opts[:box_name]).to eq("foo")
expect(opts[:force_confirm_box_remove]).to be_false
true
}
subject.execute
end
context "with --force" do
let(:argv) { super() + ["--force"] }
it "invokes the action runner with force option" do
expect(action_runner).to receive(:run).with { |action, opts|
expect(opts[:box_name]).to eq("foo")
expect(opts[:force_confirm_box_remove]).to be_true
true
}
subject.execute
end
end
end
context "with two arguments" do