From 13e64fe9d72a0207ff65a35242d855cd3c55dd43 Mon Sep 17 00:00:00 2001 From: Max Martin Date: Mon, 18 Apr 2011 11:06:39 -0700 Subject: (#7131) Remove support for optional arguments to options As per the design decision documented in #7131, optional arguments to options will no longer be supported. This patch causes such optional arguments to raise an error, and tests for this behavior. Also cleaned up some confusing use of the term "subject" in specs. Paired-with: Daniel Pittman --- lib/puppet/interface/option.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/interface/option.rb b/lib/puppet/interface/option.rb index c04c2bf67..5c75ffdd8 100644 --- a/lib/puppet/interface/option.rb +++ b/lib/puppet/interface/option.rb @@ -45,8 +45,9 @@ class Puppet::Interface::Option # Is our argument optional? The rules about consistency apply here, also, # just like they do to taking arguments at all. --daniel 2011-03-30 - @optional_argument = @optparse.any? { |o| o.include? "[" } - if @optional_argument and not @optparse.all? { |o| o.include? "[" } then + @optional_argument = @optparse.any? { |o| o=~/[ =]\[/ } + @optional_argument and raise ArgumentError, "Options with optional arguments are not supported" + if @optional_argument and not @optparse.all? { |o| o=~/[ =]\[/ } then raise ArgumentError, "Option #{@name} is inconsistent about the argument being optional" end end -- cgit