summaryrefslogtreecommitdiff
path: root/bin/pry
diff options
context:
space:
mode:
authorJohn Mair <jrmair@gmail.com>2011-12-07 15:07:02 +1300
committerJohn Mair <jrmair@gmail.com>2011-12-09 03:14:33 +1300
commit9142aa173f63aadd3f0cec218479525cee9540e7 (patch)
treeea2192ccac513063bcf82871f19592b5e3cbd5ed /bin/pry
parent91a249845e2570f2d93e143c1220f4e2b9ba2318 (diff)
downloadpry-9142aa173f63aadd3f0cec218479525cee9540e7.tar.gz
Added Pry::CLI class for processing command line options, with plugin support.
Plugins can define their own command line options by having a lib/plugin_name/cli.rb file. If this file exists it is loaded immediately before command line options are processed. The contents of the file should be along the lines of: Pry::CLI.add_options do on "my-option", "My first option!" do puts "I just defined an option!" end end
Diffstat (limited to 'bin/pry')
-rwxr-xr-xbin/pry82
1 files changed, 2 insertions, 80 deletions
diff --git a/bin/pry b/bin/pry
index 43863957..cd06ba94 100755
--- a/bin/pry
+++ b/bin/pry
@@ -12,83 +12,5 @@ rescue LoadError
require 'pry'
end
-opts = Slop.parse(:help => true, :multiple_switches => false) do
- banner %{Usage: pry [OPTIONS]
-Start a Pry session.
-See: `https://github.com/pry` for more information.
-Copyright (c) 2011 John Mair (banisterfiend)
---
-}
-
- 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.config.pager = false
- end
-
- on "no-history", "Disable history loading" do
- Pry.config.history.should_load = 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." do
- puts "Installed Plugins:"
- puts "--"
- Pry.locate_plugins.each do |plugin|
- puts "#{plugin.name}".ljust(18) + plugin.spec.summary
- end
- exit
- end
-
- 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
-
-# invoked via cli
-Pry.cli = true
-
-# create the actual context
-context = Pry.binding_for(eval(opts[:context]))
-
-if opts[:exec]
- exec_string = opts[:exec] + "\n"
-else
- exec_string = ""
-end
-
-# Start the session (running any code passed with -e, if there is any)
-Pry.start(context, :input => StringIO.new(exec_string))
-
+# Process command line options and run Pry
+Pry::CLI.run