summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-11 23:09:18 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-12 16:12:09 -0700
commit826d5dff531eb624fef91a7298932e9ec5a46231 (patch)
treeee4b9ad747e36232c1693982d513711a2b066122 /lib/puppet
parent9496067f5644972def823cf8c3318aca137b86fe (diff)
downloadpuppet-826d5dff531eb624fef91a7298932e9ec5a46231.tar.gz
puppet-826d5dff531eb624fef91a7298932e9ec5a46231.tar.xz
puppet-826d5dff531eb624fef91a7298932e9ec5a46231.zip
(#6962) delegate global usage to the help face.
The global --help handler (also invoked when puppet is run without any other command line options at all) used to spit out a brief and generally not so helpful message. Now that we have a help face that can provide the same information in a much more user-friendly form, we should delegate the function to that when required. Reviewed-By: Matt Robinson <matt@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/util/command_line.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb
index 2891030df..674927842 100644
--- a/lib/puppet/util/command_line.rb
+++ b/lib/puppet/util/command_line.rb
@@ -49,26 +49,29 @@ module Puppet
self.class.available_subcommands
end
- def usage_message
- usage = "Usage: puppet command <space separated arguments>"
- available = "Available commands are: #{available_subcommands.sort.join(', ')}"
- [usage, available].join("\n")
- end
-
def require_application(application)
require File.join(appdir, application)
end
def execute
- if subcommand_name.nil?
- puts usage_message
- elsif available_subcommands.include?(subcommand_name) #subcommand
+ if subcommand_name and available_subcommands.include?(subcommand_name) then
require_application subcommand_name
app = Puppet::Application.find(subcommand_name).new(self)
Puppet::Plugins.on_application_initialization(:appliation_object => self)
app.run
+ elsif execute_external_subcommand then
+ # Logically, we shouldn't get here, but we do, so whatever. We just
+ # return to the caller. How strange we are. --daniel 2011-04-11
else
- abort "Error: Unknown command #{subcommand_name}.\n#{usage_message}" unless execute_external_subcommand
+ unless subcommand_name.nil? then
+ puts "Error: Unknown Puppet subcommand #{subcommand_name}.\n"
+ end
+
+ # Doing this at the top of the file is natural, but causes puppet.rb
+ # to load too early, which causes things to break. This is a nasty
+ # thing, found in #7065. --daniel 2011-04-11
+ require 'puppet/faces/help'
+ puts Puppet::Faces[:help, :current].help
end
end