diff --git a/lib/vagrant/plugin/v2/command.rb b/lib/vagrant/plugin/v2/command.rb index 6a9fb527e..a338b7902 100644 --- a/lib/vagrant/plugin/v2/command.rb +++ b/lib/vagrant/plugin/v2/command.rb @@ -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 diff --git a/test/unit/vagrant/plugin/v2/command_test.rb b/test/unit/vagrant/plugin/v2/command_test.rb index 555d3fbf1..add43f963 100644 --- a/test/unit/vagrant/plugin/v2/command_test.rb +++ b/test/unit/vagrant/plugin/v2/command_test.rb @@ -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| }