summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-01-12 18:51:03 +0000
committerThom May <thom@may.lt>2016-01-12 18:51:03 +0000
commit5bb3067a0cca056ad47dda1994f8c845552da6a3 (patch)
tree4f2735a9b2b6766c9e1864ec97190b22583f00b2
parentd537eef6d200f79edd22810c2021aef2aa5f8056 (diff)
parent3719d656d5aae539c860f25d18368271724760b4 (diff)
downloadchef-5bb3067a0cca056ad47dda1994f8c845552da6a3.tar.gz
Merge pull request #4373 from PatrickWalker/feature/issue-4268
Ensuring running Help returns an exit code of 0
-rw-r--r--lib/chef/application/knife.rb2
-rw-r--r--spec/functional/knife/smoke_test.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index d169a5dab5..11e3246cfb 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -162,7 +162,7 @@ class Chef::Application::Knife < Chef::Application
print_help_and_exit(1, NO_COMMAND_GIVEN)
elsif no_subcommand_given?
if (want_help? || want_version?)
- print_help_and_exit
+ print_help_and_exit(0)
else
print_help_and_exit(2, NO_COMMAND_GIVEN)
end
diff --git a/spec/functional/knife/smoke_test.rb b/spec/functional/knife/smoke_test.rb
index 607e8065cf..b718bc50e0 100644
--- a/spec/functional/knife/smoke_test.rb
+++ b/spec/functional/knife/smoke_test.rb
@@ -31,4 +31,12 @@ describe "knife smoke tests" do
knife_cmd.error!
expect(knife_cmd.stdout).to include(Chef::VERSION)
end
+
+ it "can run and show help" do
+ knife_path = File.expand_path("../../bin/knife", CHEF_SPEC_DATA)
+ knife_cmd = Mixlib::ShellOut.new("#{knife_path} --help")
+ knife_cmd.run_command
+ knife_cmd.error!
+ expect(knife_cmd.stdout).to include("Usage")
+ end
end