diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-19 21:08:05 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-20 14:12:49 -0700 |
| commit | 379b46d4b9e2a57f954ff178956ca6850c3c56f7 (patch) | |
| tree | cefc2b0b6e5dc40db8fcfd2d6363c0db7f8a30b7 /lib | |
| parent | a1db58528f2baf7867202058d80e66f23fb447e0 (diff) | |
| download | puppet-379b46d4b9e2a57f954ff178956ca6850c3c56f7.tar.gz puppet-379b46d4b9e2a57f954ff178956ca6850c3c56f7.tar.xz puppet-379b46d4b9e2a57f954ff178956ca6850c3c56f7.zip | |
(#7116) Handle application-level options in parse_options
We hid another layer of per-application option in the class backing the
application, which wasn't correctly handled in the parse_options method.
They are now found and handled, so that global flags like --debug work as
expected on the left of the action, not just the right.
Reviewed-By: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/application/face_base.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index fabe71896..7bebd18bb 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -122,6 +122,8 @@ class Puppet::Application::FaceBase < Puppet::Application # a mandatory argument. --daniel 2011-04-05 index += 1 # ...so skip the argument. end + elsif option = find_application_argument(item) then + index += 1 if (option[:argument] and option[:optional]) else raise OptionParser::InvalidOption.new(item.sub(/=.*$/, '')) end @@ -158,6 +160,21 @@ class Puppet::Application::FaceBase < Puppet::Application return nil # nothing found. end + def find_application_argument(item) + self.class.option_parser_commands.each do |options, function| + options.each do |option| + next unless option =~ /^-/ + pattern = /^#{option.sub('[no-]', '').sub(/[ =].*$/, '')}(?:[ =].*)?$/ + next unless pattern.match(item) + return { + :argument => option =~ /[ =]/, + :optional => option =~ /[ =]\[/ + } + end + end + return nil # not found + end + def setup Puppet::Util::Log.newdestination :console |
