1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/bin/pry

79 lines
1.7 KiB
Text
Raw Normal View History

#!/usr/bin/env ruby
# (C) John Mair (banisterfiend)
# MIT license
2011-05-03 09:58:54 -04:00
$0 = 'pry'
begin
require 'pry'
rescue LoadError
require 'rubygems'
require 'pry'
end
2011-04-24 10:33:34 -04:00
opts = Slop.parse(:help => true) do
2011-04-19 08:13:22 -04:00
banner %{Usage: pry [OPTIONS]
Start a Pry session.
See: `https://github.com/banister` for more information.
--
}
2011-04-19 08:13:22 -04:00
on :e, :exec, "A line of code to execute in context before the session starts", true
on "no-pager", "Disable pager for long output" do
Pry.pager = false
end
on "no-color", "Disable syntax highlighting for session" do
Pry.color = false
end
on :f, "Suppress loading of ~/.pryrc" do
# load ~/.pryrc, if not suppressed with -f option
Pry.config.should_load_rc = false
end
on "no-plugins", "Suppress loading of plugins." do
# suppress plugins if given --no-plugins optino
Pry.config.plugins.enabled = false
end
2011-04-19 08:13:22 -04:00
on "simple-prompt", "Enable simple prompt mode" do
Pry.prompt = Pry::SIMPLE_PROMPT
end
2011-04-19 08:13:22 -04:00
on :r, :require, "`require` a Ruby script at startup", true do |file|
require file
end
2011-04-19 08:13:22 -04:00
on :I, "Add a path to the $LOAD_PATH", true do |path|
$LOAD_PATH << path
end
2011-04-19 08:13:22 -04:00
on :v, :version, "Display the Pry version" do
puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
exit
end
2011-04-19 08:13:22 -04:00
on(:c, :context,
"Start the session in the specified context. Equivalent to `context.pry` in a session.",
true,
:default => "TOPLEVEL_BINDING"
)
end
# invoked via cli
Pry.cli = true
# create the actual context
2011-04-19 08:13:22 -04:00
context = Pry.binding_for(eval(opts[:context]))
# run code passed with `-e`, if there is any.
2011-04-19 08:13:22 -04:00
if opts.exec?
Pry.new(:input => StringIO.new(opts[:exec]), :print => proc {}).rep(context)
end
# start the session
context.pry