summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJohn Mair <jrmair@gmail.com>2011-02-21 13:46:29 +1300
committerJohn Mair <jrmair@gmail.com>2011-02-21 13:46:29 +1300
commitd65a13ae30f8288827c645a15e9c5e0b2d5785de (patch)
treea05d3342bcb7d17d917c44402f94abba272bf331 /bin
parent22d31c0b92db2772acb53f817c0b2aa32793f351 (diff)
downloadpry-d65a13ae30f8288827c645a15e9c5e0b2d5785de.tar.gz
version 0.5.8 added -c (context) options to show-method and show-doc and eval-file commands, fixed up ordering issue for options in pry command line
Diffstat (limited to 'bin')
-rw-r--r--bin/pry20
1 files changed, 14 insertions, 6 deletions
diff --git a/bin/pry b/bin/pry
index 6d2f0d18..b231b009 100644
--- a/bin/pry
+++ b/bin/pry
@@ -9,11 +9,11 @@ rescue LoadError
require 'rubygems'
require 'pry'
end
-require "optparse"
+require 'optparse'
# defaults
options = {
- :context => TOPLEVEL_BINDING,
+ :context_string => "TOPLEVEL_BINDING",
:loadrc => true
}
@@ -42,22 +42,30 @@ See: `https://github.com/banister` for more information.
opts.on("-c", "--context CONTEXT",
"Start the session in the specified context. Equivalent to `context.pry` in a session.") do |context|
- options[:context] = Pry.binding_for(eval(context))
+
+ # save the context name
+ options[:context_string] = context
end
opts.on_tail("-h", "--help", "This message.") do
puts opts
exit
end
-end.parse!
+end.permute!
rcpath = File.expand_path("~/.pryrc")
# load ~/.pryrc, if not suppressed with -f option
load rcpath if File.exists?(rcpath) && options[:loadrc]
+# create the actual context
+context = Pry.binding_for(eval(options[:context_string]))
+
# execute line of code, if provided with -e option
-options[:context].eval(options[:code]) if options[:code]
+if options[:code]
+ result = context.eval(options[:code])
+ puts "=> #{Pry.view(result)}"
+end
# start the session
-options[:context].pry
+context.pry