From 901bc7b3587c2ed488f58e03abac6fc0f8079436 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 13 Jan 2012 00:08:52 -0800 Subject: [PATCH] Don't break "help" if description is omitted --- lib/pry/command_set.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index 432f5420..34bf6b5f 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -82,6 +82,7 @@ class Pry # # pry(main)> help number # # number-N regex command 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) commands[name] = Pry::BlockCommand.subclass(name, description, options, helper_module, &block) @@ -114,6 +115,7 @@ class Pry # end # 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) commands[name] = Pry::ClassCommand.subclass(name, description, options, helper_module, &block) @@ -336,7 +338,7 @@ class Pry help_text << commands.map do |key, command| if command.description && !command.description.empty? - "#{command.options[:listing]}".ljust(18) + command.description + "#{command.options[:listing].to_s.ljust(18)} #{command.description}" end end.compact.sort.join("\n")