Sha256: de637ec2936dbe3afe44f3fa15e0f11b9aca4d24f0c3c9cd0360ce815e0bfdb3

Contents?: true

Size: 1.93 KB

Versions: 35

Compression:

Stored size: 1.93 KB

Contents

#!/usr/bin/env ruby

# (C) John Mair (banisterfiend)
# MIT license

$0 = 'pry'

begin
  require 'pry'
rescue LoadError
  require 'rubygems'
  require 'pry'
end

opts = Slop.parse(:help => true) do
  banner %{Usage: pry [OPTIONS]
Start a Pry session.
See: `https://github.com/banister` for more information.
--
}

  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

  on "installed-plugins", "List installed plugins."

  on "simple-prompt", "Enable simple prompt mode" do
    Pry.prompt = Pry::SIMPLE_PROMPT
  end

  on :r, :require, "`require` a Ruby script at startup", true do |file|
    Pry.config.requires << file
  end

  on :I, "Add a path to the $LOAD_PATH", true do |path|
    $LOAD_PATH << path
  end

  on :v, :version, "Display the Pry version" do
    puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
    exit
  end

  on(:c, :context,
    "Start the session in the specified context. Equivalent to `context.pry` in a session.",
    true,
    :default => "TOPLEVEL_BINDING"
    )
end

if opts["installed-plugins"]
  puts "Installed Plugins:"
  puts "--"
  Pry.locate_plugins.each do |plugin|
    puts "#{plugin.name}".ljust(18) + plugin.spec.summary
  end
  exit
end

# invoked via cli
Pry.cli = true

# create the actual context
context = Pry.binding_for(eval(opts[:context]))

# run code passed with `-e`, if there is any.
if opts.exec?
  Pry.new(:input => StringIO.new(opts[:exec]), :print => proc {}).rep(context)
end

# start the session
context.pry

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
pry-0.9.5 bin/pry
pry-0.9.5-i386-mswin32 bin/pry
pry-0.9.5-i386-mingw32 bin/pry
pry-0.9.5-java bin/pry
pry-0.9.4pre6 bin/pry
pry-0.9.4pre6-i386-mswin32 bin/pry
pry-0.9.4pre6-i386-mingw32 bin/pry
pry-0.9.4pre6-java bin/pry
pry-0.9.4-i386-mswin32 bin/pry
pry-0.9.4-i386-mingw32 bin/pry
pry-0.9.4pre5 bin/pry
pry-0.9.4pre5-i386-mswin32 bin/pry
pry-0.9.4pre5-i386-mingw32 bin/pry
pry-0.9.4pre5-java bin/pry
pry-0.9.4pre4 bin/pry
pry-0.9.4pre4-i386-mswin32 bin/pry
pry-0.9.4pre4-i386-mingw32 bin/pry
pry-0.9.4pre4-java bin/pry
pry-0.9.4pre3 bin/pry
pry-0.9.4pre3-i386-mswin32 bin/pry