commands/box/remove: add --force flag
This commit is contained in:
parent
85f4a4d5ee
commit
5da77dee5c
|
@ -6,11 +6,17 @@ module VagrantPlugins
|
||||||
class Remove < Vagrant.plugin("2", :command)
|
class Remove < Vagrant.plugin("2", :command)
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
|
options[:force] = false
|
||||||
|
|
||||||
opts = OptionParser.new do |o|
|
opts = OptionParser.new do |o|
|
||||||
o.banner = "Usage: vagrant box remove <name>"
|
o.banner = "Usage: vagrant box remove <name>"
|
||||||
o.separator ""
|
o.separator ""
|
||||||
o.separator "Options:"
|
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,
|
o.on("--provider PROVIDER", String,
|
||||||
"The specific provider type for the box to remove") do |p|
|
"The specific provider type for the box to remove") do |p|
|
||||||
|
@ -43,6 +49,7 @@ module VagrantPlugins
|
||||||
:box_name => argv[0],
|
:box_name => argv[0],
|
||||||
:box_provider => options[:provider],
|
:box_provider => options[:provider],
|
||||||
:box_version => options[:version],
|
:box_version => options[:version],
|
||||||
|
:force_confirm_box_remove => options[:force],
|
||||||
})
|
})
|
||||||
|
|
||||||
# Success, exit status 0
|
# Success, exit status 0
|
||||||
|
|
|
@ -34,11 +34,26 @@ describe VagrantPlugins::CommandBox::Command::Remove do
|
||||||
it "invokes the action runner" do
|
it "invokes the action runner" do
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with { |action, opts|
|
||||||
expect(opts[:box_name]).to eq("foo")
|
expect(opts[:box_name]).to eq("foo")
|
||||||
|
expect(opts[:force_confirm_box_remove]).to be_false
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "with two arguments" do
|
context "with two arguments" do
|
||||||
|
|
Loading…
Reference in New Issue