diff options
author | John Mair <jrmair@gmail.com> | 2011-02-21 13:46:29 +1300 |
---|---|---|
committer | John Mair <jrmair@gmail.com> | 2011-02-21 13:46:29 +1300 |
commit | d65a13ae30f8288827c645a15e9c5e0b2d5785de (patch) | |
tree | a05d3342bcb7d17d917c44402f94abba272bf331 /bin | |
parent | 22d31c0b92db2772acb53f817c0b2aa32793f351 (diff) | |
download | pry-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/pry | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -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 |