summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface/option.rb
diff options
context:
space:
mode:
authorMax Martin <max@puppetlabs.com>2011-04-18 11:06:39 -0700
committerMax Martin <max@puppetlabs.com>2011-04-18 11:41:47 -0700
commit13e64fe9d72a0207ff65a35242d855cd3c55dd43 (patch)
tree74a7890a42d49f49619a4e297c640f9d2a674956 /lib/puppet/interface/option.rb
parent7e9b45d604148d48b90e84bb091d751f3d393874 (diff)
downloadpuppet-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.rb5
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