diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-29 15:34:23 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-04 10:19:53 -0700 |
commit | a113e8f03d257375bf4eb2416a6ad7e1958d7868 (patch) | |
tree | 6004a5b057caf49ac51357c7ff087ad6a7d06a56 /lib/puppet/string/option_builder.rb | |
parent | 5bba1a26140cd3326739b00c2d60dff9321d4044 (diff) | |
download | puppet-a113e8f03d257375bf4eb2416a6ad7e1958d7868.tar.gz puppet-a113e8f03d257375bf4eb2416a6ad7e1958d7868.tar.xz puppet-a113e8f03d257375bf4eb2416a6ad7e1958d7868.zip |
(#6749) implementing option handling in CLI string wrapper
The purpose of this is to adapt the generic option support in our strings to
the command line; we adapt the generic option information to optparse, and
establish our environment early in the process to ensure that we can play nice
with Puppet::Application for the moment.
In the process we ensure that we detect, and report, conflicts in option
naming across the board. Additionally, when an option is declared with
multiple aliases, we insist that either all, or none, of them take an
argument.
To support this we support introspecting options having an optional argument,
as well as documentation and all.
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'lib/puppet/string/option_builder.rb')
-rw-r--r-- | lib/puppet/string/option_builder.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/puppet/string/option_builder.rb b/lib/puppet/string/option_builder.rb index 2087cbc99..da0d213fb 100644 --- a/lib/puppet/string/option_builder.rb +++ b/lib/puppet/string/option_builder.rb @@ -3,14 +3,14 @@ require 'puppet/string/option' class Puppet::String::OptionBuilder attr_reader :option - def self.build(string, name, attrs = {}, &block) - new(string, name, attrs, &block).option + def self.build(string, *declaration, &block) + new(string, *declaration, &block).option end private - def initialize(string, name, attrs, &block) + def initialize(string, *declaration, &block) @string = string - @option = Puppet::String::Option.new(string, name, attrs) + @option = Puppet::String::Option.new(string, *declaration) block and instance_eval(&block) @option end |