mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Don't break "help" if description is omitted
This commit is contained in:
parent
6280417ad9
commit
901bc7b358
1 changed files with 3 additions and 1 deletions
|
@ -82,6 +82,7 @@ class Pry
|
||||||
# # pry(main)> help number
|
# # pry(main)> help number
|
||||||
# # number-N regex command
|
# # number-N regex command
|
||||||
def block_command(name, description="No description.", options={}, &block)
|
def block_command(name, description="No description.", options={}, &block)
|
||||||
|
description, options = ["No description.", description] if description.is_a?(Hash)
|
||||||
options = default_options(name).merge!(options)
|
options = default_options(name).merge!(options)
|
||||||
|
|
||||||
commands[name] = Pry::BlockCommand.subclass(name, description, options, helper_module, &block)
|
commands[name] = Pry::BlockCommand.subclass(name, description, options, helper_module, &block)
|
||||||
|
@ -114,6 +115,7 @@ class Pry
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
def create_command(name, description="No description.", options={}, &block)
|
def create_command(name, description="No description.", options={}, &block)
|
||||||
|
description, options = ["No description.", description] if description.is_a?(Hash)
|
||||||
options = default_options(name).merge!(options)
|
options = default_options(name).merge!(options)
|
||||||
|
|
||||||
commands[name] = Pry::ClassCommand.subclass(name, description, options, helper_module, &block)
|
commands[name] = Pry::ClassCommand.subclass(name, description, options, helper_module, &block)
|
||||||
|
@ -336,7 +338,7 @@ class Pry
|
||||||
|
|
||||||
help_text << commands.map do |key, command|
|
help_text << commands.map do |key, command|
|
||||||
if command.description && !command.description.empty?
|
if command.description && !command.description.empty?
|
||||||
"#{command.options[:listing]}".ljust(18) + command.description
|
"#{command.options[:listing].to_s.ljust(18)} #{command.description}"
|
||||||
end
|
end
|
||||||
end.compact.sort.join("\n")
|
end.compact.sort.join("\n")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue