diff options
author | Max Martin <max@puppetlabs.com> | 2011-04-18 11:06:39 -0700 |
---|---|---|
committer | Max Martin <max@puppetlabs.com> | 2011-04-18 11:41:47 -0700 |
commit | 13e64fe9d72a0207ff65a35242d855cd3c55dd43 (patch) | |
tree | 74a7890a42d49f49619a4e297c640f9d2a674956 /lib/puppet/interface/option.rb | |
parent | 7e9b45d604148d48b90e84bb091d751f3d393874 (diff) | |
download | puppet-13e64fe9d72a0207ff65a35242d855cd3c55dd43.tar.gz puppet-13e64fe9d72a0207ff65a35242d855cd3c55dd43.tar.xz puppet-13e64fe9d72a0207ff65a35242d855cd3c55dd43.zip |
(#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
Diffstat (limited to 'lib/puppet/interface/option.rb')
-rw-r--r-- | lib/puppet/interface/option.rb | 5 |
1 files changed, 3 insertions, 2 deletions
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 |