[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Daniel Pittman
daniel at puppetlabs.com
Tue May 10 08:13:26 UTC 2011
The following commit has been merged in the experimental branch:
commit 826d5dff531eb624fef91a7298932e9ec5a46231
Author: Daniel Pittman <daniel at puppetlabs.com>
Date: Mon Apr 11 23:09:18 2011 -0700
(#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 at puppetlabs.com>
diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb
index 2891030..6749278 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
diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb
index 5b25ab7..a1b5eb1 100755
--- a/spec/unit/application/cert_spec.rb
+++ b/spec/unit/application/cert_spec.rb
@@ -1,7 +1,5 @@
-#!/usr/bin/env ruby
-
+#!/usr/bin/env rspec
require 'spec_helper'
-
require 'puppet/application/cert'
describe Puppet::Application::Cert do
@@ -189,16 +187,6 @@ describe Puppet::Application::Cert do
@cert_app.ca = @ca
end
- it "should SystemExit after printing help message" do
- # Make the help method silent for testing; this is a bit nasty, but we
- # can't identify a cleaner method. Help welcome. --daniel 2011-02-22
- Puppet.features.stubs(:usage?).returns(false)
- @cert_app.stubs(:puts)
-
- @cert_app.command_line.stubs(:args).returns([])
- expect { @cert_app.parse_options }.should raise_error SystemExit
- end
-
%w{list revoke generate sign print verify fingerprint}.each do |cmd|
short = cmd[0,1]
[cmd, "--#{cmd}", "-#{short}"].each do |option|
diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb
index c5c6e5f..6cf9047 100755
--- a/spec/unit/util/command_line_spec.rb
+++ b/spec/unit/util/command_line_spec.rb
@@ -99,10 +99,11 @@ describe Puppet::Util::CommandLine do
Puppet::Util.expects(:which).with('puppet-whatever').returns(nil)
commandline.expects(:system).never
- commandline.expects(:usage_message).returns("the usage message")
- commandline.expects(:abort).with{|x| x =~ /the usage message/}.raises("stubbed abort")
+ text = Puppet::Faces[:help, :current].help
+ commandline.expects(:puts).with { |x| x =~ /Unknown Puppet subcommand/ }
+ commandline.expects(:puts).with text
- lambda{ commandline.execute }.should raise_error('stubbed abort')
+ commandline.execute
end
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list