Permalink
Browse files

Handle case where help method is called with no command.

  • Loading branch information...
1 parent 0185a1e commit 4159251bb749d913ae264e0e5d561c2ed6bb9e8d @celldee celldee committed Apr 6, 2012
Showing with 13 additions and 5 deletions.
  1. +7 −3 lib/boson/runner.rb
  2. +6 −2 test/runner_test.rb
View
@@ -91,9 +91,13 @@ def new_attributes(name, library)
# Defines default commands that are available to executables i.e. Runner.start
class DefaultCommandsRunner < Runner
desc "Displays help for a command"
- def help(cmd)
- (cmd_obj = Command.find(cmd)) ? Runner.current.display_command_help(cmd_obj) :
- self.class.no_command_error(cmd)
+ def help(cmd = nil)
+ if cmd.nil?
+ Runner.current.display_help()
+ else
+ (cmd_obj = Command.find(cmd)) ? Runner.current.display_command_help(cmd_obj) :
+ self.class.no_command_error(cmd)
+ end
end
end
end
View
@@ -130,6 +130,10 @@ def default_usage
with("my_command: Could not find command \"invalid\"")
my_command('help invalid')
end
+
+ it 'prints general help if no command' do
+ my_command('help').should == default_usage
+ end
end
describe "for COMMAND -h" do
@@ -285,7 +289,7 @@ def default_usage
describe "extend Runner" do
it "can extend help" do
extended_command('help help').should == <<-STR
-Usage: extended_command help CMD
+Usage: extended_command help [CMD]
Description:
Displays help for a command
@@ -295,7 +299,7 @@ def default_usage
it "can extend a command's --help" do
extended_command('help -h').should == <<-STR
-Usage: extended_command help CMD
+Usage: extended_command help [CMD]
Description:
Displays help for a command

0 comments on commit 4159251

Please sign in to comment.