Merge pull request #11746 from soapy1/ambiguous-option
Print help message if user provides and ambiguous option
This commit is contained in:
commit
9da33520e8
@ -61,7 +61,7 @@ module Vagrant
|
||||
|
||||
opts.parse!(argv)
|
||||
return argv
|
||||
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
||||
rescue OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::AmbiguousOption
|
||||
raise Errors::CLIInvalidOptions, help: opts.help.chomp
|
||||
end
|
||||
|
||||
|
||||
@ -46,6 +46,12 @@ describe Vagrant::Plugin::V2::Command do
|
||||
to raise_error(Vagrant::Errors::CLIInvalidOptions)
|
||||
end
|
||||
|
||||
it "raises an error if ambiguous options are given" do
|
||||
instance = klass.new(["-provision"], nil)
|
||||
expect { instance.parse_options(OptionParser.new) }.
|
||||
to raise_error(Vagrant::Errors::CLIInvalidOptions)
|
||||
end
|
||||
|
||||
it "raises an error if options without a value are given" do
|
||||
opts = OptionParser.new do |o|
|
||||
o.on("--provision-with x,y,z", Array, "Example") { |f| }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user