summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface/option.rb
diff options
context:
space:
mode:
authorPieter van de Bruggen <pieter@puppetlabs.com>2011-04-17 22:23:44 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-17 22:23:44 -0700
commit9d2ec219bbd77bfca48a72b52fe5d0d3fcc0dcf7 (patch)
tree1b01ad690ce899fb688356ac2deb7eed4f50c302 /lib/puppet/interface/option.rb
parent0d0318f9f0eadff7f9934d3d02a7081bba05164c (diff)
downloadpuppet-9d2ec219bbd77bfca48a72b52fe5d0d3fcc0dcf7.tar.gz
puppet-9d2ec219bbd77bfca48a72b52fe5d0d3fcc0dcf7.tar.xz
puppet-9d2ec219bbd77bfca48a72b52fe5d0d3fcc0dcf7.zip
(#7013) Add support for required options.
This adds another hook into the generated wrapper, which invokes a method to validate arguments. This is used to raise an exception when required options have not been passed to the method. Reviewed-By: Daniel Pittman <daniel@puppetlabs.com>
Diffstat (limited to 'lib/puppet/interface/option.rb')
-rw-r--r--lib/puppet/interface/option.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/puppet/interface/option.rb b/lib/puppet/interface/option.rb
index 2abcd4033..c04c2bf67 100644
--- a/lib/puppet/interface/option.rb
+++ b/lib/puppet/interface/option.rb
@@ -74,10 +74,12 @@ class Puppet::Interface::Option
def optional_argument?
!!@optional_argument
end
-
+ def required?
+ !!@required
+ end
attr_reader :parent, :name, :aliases, :optparse
- attr_accessor :desc
+ attr_accessor :required, :desc
attr_accessor :before_action
def before_action=(proc)