Running `puppet help inspect` did not result in help: Unable to find application 'inspect'. err: exit err: Try 'puppet help help help' for usage
It turned out that the only reason applications were getting required so that their help could be found was the LegacyName conversion table in lib/puppet/util/command_line.rb:7. Inspect never had a legacy name, so the help system couldn't find it since it never got required. Now instead of checking for the class constant to see if the application has been loaded, we try to require the application and exit if it's not found. Reviewed-by: Nick Lewis <n...@puppetlabs.com> Signed-off-by: Matt Robinson <m...@puppetlabs.com> --- Local-branch: ticket/2.7.x/maint-fix_inspect_help lib/puppet/application.rb | 9 ++++----- spec/unit/application_spec.rb | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 374dc85..1e00bcc 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -215,11 +215,10 @@ class Application def find(name) klass = name.to_s.capitalize - # const_defined? is used before const_get since const_defined? will only - # check within our namespace, whereas const_get will check ancestor - # trees as well, resulting in unexpected behaviour. - if !self.const_defined?(klass) - puts "Unable to find application '#{name.to_s}'." + begin + require File.join('puppet', 'application', name.to_s) + rescue LoadError => e + puts "Unable to find application '#{name}'. #{e}" Kernel::exit(1) end diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index aed80e3..b56aa20 100755 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -31,6 +31,10 @@ describe Puppet::Application do end it "should exit if it can't find a class" do + reg = "Unable to find application 'ThisShallNeverEverEverExist'. " + reg += "no such file to load -- puppet/application/ThisShallNeverEverEverExist" + @klass.expects(:puts).with(reg) + expect { @klass.find("ThisShallNeverEverEverExist") }.to exit_with 1 end end -- 1.7.3.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.