Skip to content

Commit

Permalink
Omitting all descs doesn't cause an exception
Browse files Browse the repository at this point in the history
Fixes #48
  • Loading branch information
davetron5000 committed Aug 24, 2011
1 parent d65d956 commit fb84cc3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/support/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def output_command_tokens_for_help(tokens,usage_name=:usage)
# Assumes that the first line doesn't need the padding, as its filled
# up with other stuff
def wrap(line,pad_length=0,line_length=nil)
line ||= ''
if line_length.nil?
line_length = Terminal.instance.size[0]
end
Expand Down
5 changes: 4 additions & 1 deletion test/fake_std_out.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
class FakeStdOut
attr_reader :strings

def initialize
@strings = []
end
def puts(string=nil)
@strings ||= []
@strings << string unless string.nil?
end

Expand Down
11 changes: 11 additions & 0 deletions test/tc_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ def test_help_no_global_options
assert_not_contained(@fake_stdout,/\[global options\]/)
end

def test_help_without_any_descs_still_works
GLI.reset
GLI.flag :f
GLI.command :foo do |c|
end
exit_status = GLI.run(%w(help foo))
assert_not_contained(@fake_stderr,/nil/)
assert_not_contained(@fake_stdout,/nil/)
assert_equal exit_status,0
end

def test_help_one_command
args = %w(help basic)
GLI.run(args)
Expand Down

0 comments on commit fb84cc3

Please sign in to comment.