Sha256: a6ddd4e29f896cabd5b9ed395377321a5d6eb0bd3ffa09acf3cc0e81838aaaa8
Contents?: true
Size: 1.65 KB
Versions: 6
Compression:
Stored size: 1.65 KB
Contents
#!/usr/bin/env ruby # (C) John Mair (banisterfiend) # MIT license begin require 'pry' rescue LoadError require 'rubygems' require 'pry' end require 'optparse' # defaults options = { :context_string => "TOPLEVEL_BINDING", :loadrc => true } OptionParser.new do |opts| opts.banner = %{Usage: pry [OPTIONS] Start a Pry session. See: `https://github.com/banister` for more information. -- } opts.on("-r", "--require FILE", "`require` a Ruby script at startup.") do |file| require file end opts.on("-e", "--exec CODE", "A line of Ruby code to execute in context before the session starts.") do |code| options[:code] = code end opts.on("-f", "Suppress loading of ~/.pryrc") do options[:loadrc] = false end opts.on("-v", "--version", "Display the Pry version.") do puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}" exit end opts.on("-c", "--context CONTEXT", "Start the session in the specified context. Equivalent to `context.pry` in a session.") do |context| # save the context name options[:context_string] = context end opts.on_tail("-h", "--help", "This message.") do puts opts exit end end.parse! 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])) # run code passed with `-e`, if there is any. if options[:code] Pry.new(:input => StringIO.new(options[:code]), :print => proc {}).rep(context) end # start the session context.pry
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
pry-0.6.6 | bin/pry |
pry-0.6.5 | bin/pry |
pry-0.6.4 | bin/pry |
pry-0.6.3 | bin/pry |
pry-0.6.2 | bin/pry |
pry-0.6.1 | bin/pry |