In 2.6.x this was the behavior, but the changes to the way options
parsing worked in 2.7.x to support faces changed the behavior of how
help was called.
This resulted in the follow unhelpful error message when you just called
`puppet cert`:
/Users/matthewrobinson/work/puppet/lib/puppet/ssl/certificate_authority/interface.rb:85:in
`method='
Invalid method to apply
Reviewed-by: Pieter van de Bruggen <[email protected]>
Signed-off-by: Matt Robinson <[email protected]>
---
Local-branch: ticket/2.7.x/maint-show_help_for_cert_without_subcommand
lib/puppet/application/cert.rb | 3 ++-
spec/unit/application/cert_spec.rb | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/application/cert.rb b/lib/puppet/application/cert.rb
index 162672b..330fba8 100644
--- a/lib/puppet/application/cert.rb
+++ b/lib/puppet/application/cert.rb
@@ -218,7 +218,8 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the
Apache 2.0 License
if sub = self.command_line.args.shift then
self.subcommand = sub
else
- help
+ puts help
+ exit
end
end
result
diff --git a/spec/unit/application/cert_spec.rb
b/spec/unit/application/cert_spec.rb
index 7510f07..300234c 100755
--- a/spec/unit/application/cert_spec.rb
+++ b/spec/unit/application/cert_spec.rb
@@ -208,5 +208,15 @@ describe Puppet::Application::Cert, :'fails_on_ruby_1.9.2'
=> true do
args.should == ["fun.example.com"]
end
end
+
+ it "should print help and exit if there is no subcommand" do
+ args = []
+ @cert_app.command_line.stubs(:args).returns(args)
+ @cert_app.stubs(:help).returns("I called for help!")
+ @cert_app.expects(:puts).with("I called for help!")
+
+ expect { @cert_app.parse_options }.to exit_with 0
+ @cert_app.subcommand.should be_nil
+ end
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.