Raise error if argument is provided with `--all-global` flag
This commit raises an error if additional arguments are provided to the suspend command when the `--all-global` flag is used.
This commit is contained in:
parent
aa5687cd14
commit
5ca382727d
|
@ -300,6 +300,10 @@ module Vagrant
|
|||
error_key(:command_deprecated)
|
||||
end
|
||||
|
||||
class CommandSuspendAllArgs < VagrantError
|
||||
error_key(:command_suspend_all_arguments)
|
||||
end
|
||||
|
||||
class CommandUnavailable < VagrantError
|
||||
error_key(:command_unavailable)
|
||||
end
|
||||
|
|
|
@ -24,6 +24,10 @@ module VagrantPlugins
|
|||
@logger.debug("'suspend' each target VM...")
|
||||
target = []
|
||||
if options[:all]
|
||||
if argv.size > 0
|
||||
raise Vagrant::Errors::CommandSuspendAllArgs
|
||||
end
|
||||
|
||||
m = @env.machine_index.each { |m| m }
|
||||
target = m.keys
|
||||
else
|
||||
|
|
|
@ -727,6 +727,8 @@ en:
|
|||
command_deprecated: |-
|
||||
The command 'vagrant %{name}' has been deprecated and is no longer functional
|
||||
within Vagrant.
|
||||
command_suspend_all_arguments: |-
|
||||
The suspend command with the `--all-global` flag does not take any arguments.
|
||||
command_unavailable: |-
|
||||
The executable '%{file}' Vagrant is trying to run was not
|
||||
found in the PATH variable. This is an error. Please verify
|
||||
|
|
|
@ -99,5 +99,13 @@ describe VagrantPlugins::CommandSuspend::Command do
|
|||
|
||||
expect(subject.execute).to eq(0)
|
||||
end
|
||||
|
||||
context "with an argument is used" do
|
||||
let(:argv){ ["machine", "--all-global"] }
|
||||
|
||||
it "errors out" do
|
||||
expect{subject.execute}.to raise_error(Vagrant::Errors::CommandSuspendAllArgs)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue