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)
|
error_key(:command_deprecated)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class CommandSuspendAllArgs < VagrantError
|
||||||
|
error_key(:command_suspend_all_arguments)
|
||||||
|
end
|
||||||
|
|
||||||
class CommandUnavailable < VagrantError
|
class CommandUnavailable < VagrantError
|
||||||
error_key(:command_unavailable)
|
error_key(:command_unavailable)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,6 +24,10 @@ module VagrantPlugins
|
||||||
@logger.debug("'suspend' each target VM...")
|
@logger.debug("'suspend' each target VM...")
|
||||||
target = []
|
target = []
|
||||||
if options[:all]
|
if options[:all]
|
||||||
|
if argv.size > 0
|
||||||
|
raise Vagrant::Errors::CommandSuspendAllArgs
|
||||||
|
end
|
||||||
|
|
||||||
m = @env.machine_index.each { |m| m }
|
m = @env.machine_index.each { |m| m }
|
||||||
target = m.keys
|
target = m.keys
|
||||||
else
|
else
|
||||||
|
|
|
@ -727,6 +727,8 @@ en:
|
||||||
command_deprecated: |-
|
command_deprecated: |-
|
||||||
The command 'vagrant %{name}' has been deprecated and is no longer functional
|
The command 'vagrant %{name}' has been deprecated and is no longer functional
|
||||||
within Vagrant.
|
within Vagrant.
|
||||||
|
command_suspend_all_arguments: |-
|
||||||
|
The suspend command with the `--all-global` flag does not take any arguments.
|
||||||
command_unavailable: |-
|
command_unavailable: |-
|
||||||
The executable '%{file}' Vagrant is trying to run was not
|
The executable '%{file}' Vagrant is trying to run was not
|
||||||
found in the PATH variable. This is an error. Please verify
|
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)
|
expect(subject.execute).to eq(0)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue