From dd3aaf71327e4a4519a5f1aa0d6473da49a3cbaf Mon Sep 17 00:00:00 2001 From: John Mair Date: Sat, 28 May 2011 04:11:06 +1200 Subject: [PATCH] added find_command() to base_helpers to allow commands to look up a command by :listing name --- lib/pry/helpers/base_helpers.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pry/helpers/base_helpers.rb b/lib/pry/helpers/base_helpers.rb index f13f5ed5..bcb818f2 100644 --- a/lib/pry/helpers/base_helpers.rb +++ b/lib/pry/helpers/base_helpers.rb @@ -18,7 +18,12 @@ class Pry text.split.drop(1).join(' ') end + def find_command(name) + command_match = commands.find { |_, command| command.options[:listing] == name } + return command_match.last if command_match + nil + end def gem_installed?(gem_name) require 'rubygems'