Skip to content

Commit

Permalink
omitted desc + default_command no longer crashes
Browse files Browse the repository at this point in the history
Seems if you omit the description for a comamnd, and then make
that command the default command in a subcommand setup,
we tried to plus nil, which doesn't work.

Hopefully closes #131
  • Loading branch information
davetron5000 committed Mar 17, 2013
1 parent f7589bd commit 7e355a7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/gli/commands/help_modules/command_help_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def global_flags_and_switches
def format_subcommands(command)
commands_array = @sorter.call(command.commands_declaration_order).map { |cmd|
if command.get_default_command == cmd.name
[cmd.names,cmd.description + " (default)"]
[cmd.names,String(cmd.description) + " (default)"]
else
[cmd.names,cmd.description]
end
Expand Down
28 changes: 28 additions & 0 deletions test/tc_help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,34 @@ class TestApp
}
end

test_that "omitting default_description doesn't blow up" do
Given {
app = TestApp.new
app.instance_eval do
command :top do |top|
top.command :list do |list|
list.action do |g,o,a|
end
end

top.command :new do |new|
new.action do |g,o,a|
end
end

top.default_command :list
end
end
@command = GLI::Commands::Help.new(app,@output,@error)
}
When {
@code = lambda { @command.execute({},{},['top']) }
}
Then {
assert_nothing_raised(&@code)
}
end

private

def a_GLI_app(omit_options=false)
Expand Down

0 comments on commit 7e355a7

Please sign in to comment.