summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mair <jrmair@gmail.com>2011-01-26 23:13:46 +1300
committerJohn Mair <jrmair@gmail.com>2011-01-26 23:13:46 +1300
commit228b95f5166fedf24912cb51d65599ced4896c15 (patch)
treef0341d8bb70077b07614d6416f0f54565e8652e0
parent2ca16a06574f8f0c621f05d2e7bba5e0e99faf12 (diff)
downloadpry-228b95f5166fedf24912cb51d65599ced4896c15.tar.gz
added new 'alias_command' and 'desc' commands to CommandBase; also made it so show_method comamnd without parameters does a show_method on __method__
-rw-r--r--.gitignore1
-rw-r--r--Rakefile6
-rw-r--r--lib/pry/command_base.rb23
-rw-r--r--lib/pry/commands.rb6
-rw-r--r--lib/pry/pry_class.rb2
-rw-r--r--lib/pry/version.rb2
6 files changed, 35 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 6d376431..3171be1b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ Makefile
*.def
doc/
pkg/
+coverage/
.yardoc/
diff --git a/Rakefile b/Rakefile
index bb541f33..76a00e84 100644
--- a/Rakefile
+++ b/Rakefile
@@ -37,6 +37,12 @@ task :show_version do
puts "Pry version: #{Pry::VERSION}"
end
+desc "run pry"
+task :pry do
+ require "#{direc}/lib/pry.rb"
+ Pry.start
+end
+
namespace :ruby do
spec = Gem::Specification.new do |s|
apply_spec_defaults(s)
diff --git a/lib/pry/command_base.rb b/lib/pry/command_base.rb
index 39bf8ef3..8b23010e 100644
--- a/lib/pry/command_base.rb
+++ b/lib/pry/command_base.rb
@@ -83,6 +83,29 @@ class Pry
imported_hash = Hash[klass.commands.select { |k, v| names.include?(k) }]
commands.merge!(imported_hash)
end
+
+ # Create an alias for a command.
+ # @param [String] new_command The alias name.
+ # @param [String] orig_command The original command name.
+ # @example
+ # class MyCommands < Pry::CommandBase
+ # alias_command "help_alias", "help"
+ def alias_command(new_command_name, orig_command_name, desc=nil)
+ commands[new_command_name] = commands[orig_command_name].dup
+ commands[new_command_name][:description] = desc if desc
+ end
+
+ # Set the description for a command (replacing the old
+ # description.)
+ # @param [String] name The command name.
+ # @param [String] description The command description.
+ # @example
+ # class MyCommands < Pry::CommandBase
+ # desc "help", "help description"
+ # end
+ def desc(name, description)
+ commands[name][:description] = description
+ end
end
command "help", "This menu." do |cmd|
diff --git a/lib/pry/commands.rb b/lib/pry/commands.rb
index f134ea77..bd3e0129 100644
--- a/lib/pry/commands.rb
+++ b/lib/pry/commands.rb
@@ -76,12 +76,14 @@ class Pry
end
command "show_method", "Show sourcecode for method <methname>." do |meth_name|
- doc = target.eval("method(:#{meth_name})").source
+ meth_name = target.eval("__method__").to_s if !meth_name
+ puts "blah #{meth_name.to_s}"
+ doc = target.eval("method(\"#{meth_name}\")").source
output.puts doc
end
command "show_imethod", "Show sourcecode for instance method <methname>." do |meth_name|
- doc = target.eval("instance_method(:#{meth_name})").source
+ doc = target.eval("instance_method(#{meth_name})").source
output.puts doc
end
diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb
index 27319368..08584139 100644
--- a/lib/pry/pry_class.rb
+++ b/lib/pry/pry_class.rb
@@ -85,8 +85,6 @@ class Pry
def self.reset_defaults
@input = Readline
@output = $stdout
-
- # FIXME
@commands = Pry::Commands
@prompt = DEFAULT_PROMPT
@print = DEFAULT_PRINT
diff --git a/lib/pry/version.rb b/lib/pry/version.rb
index 39b92218..d1f763bb 100644
--- a/lib/pry/version.rb
+++ b/lib/pry/version.rb
@@ -1,3 +1,3 @@
class Pry
- VERSION = "0.4.1"
+ VERSION = "0.4.2pre1"
end