diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-20 14:12:59 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-20 14:12:59 -0700 |
| commit | 06d5af8dcced82d4611783d1c5fa03995d84d19c (patch) | |
| tree | cefc2b0b6e5dc40db8fcfd2d6363c0db7f8a30b7 /lib/puppet | |
| parent | 8172060684e532eaba234eb992ed739511abbe59 (diff) | |
| parent | 379b46d4b9e2a57f954ff178956ca6850c3c56f7 (diff) | |
Merge branch 'bug/2.7.x/7116-cannot-use-faces-with---debug' into 2.7.x
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/application/face_base.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index 9da48af55..7bebd18bb 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -92,8 +92,8 @@ class Puppet::Application::FaceBase < Puppet::Application # REVISIT: These should be configurable versions, through a global # '--version' option, but we don't implement that yet... --daniel 2011-03-29 - @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - @face = Puppet::Face[@type, :current] + @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym + @face = Puppet::Face[@type, :current] # Now, walk the command line and identify the action. We skip over # arguments based on introspecting the action and all, and find the first @@ -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 |
