diff --git a/CHANGELOG b/CHANGELOG index fdb6d5b3..820a322e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +21/2/2010 version 0.5.7 +* Added pry executable, auto-loads .pryrc in user's home directory, if it + exists. + 19/2/2010 version 0.5.5 * Added Pry.run_command * More useful error messages diff --git a/README.markdown b/README.markdown index bb9180bb..d672af03 100644 --- a/README.markdown +++ b/README.markdown @@ -21,6 +21,10 @@ is trivial to set it to read from any object that has a `readline` method and wr `puts` method - many other aspects of Pry are also configurable making it a good choice for implementing custom shells. +Pry now comes with an executable so it can be invoked at the command line. +Just enter `pry` to start. A `.pryrc` file in the user's home directory will +be loaded if it exists. Type `pry --help` at the command line for more information. + * Install the [gem](https://rubygems.org/gems/pry): `gem install pry` * Read the [documentation](http://rdoc.info/github/banister/pry/master/file/README.markdown) * See the [source code](http://github.com/banister/pry) @@ -180,10 +184,6 @@ invoke any of these methods directly depending on exactly what aspect of the fun ###Limitations: -* Pry does not pretend to be a replacement for `irb`, - and so does not have an executable. It is designed to be used by - other programs, not on its own. For a full-featured `irb` replacement - see [ripl](https://github.com/cldwalker/ripl) * Pry's `show-method` and `show-doc` commands do not work in Ruby 1.8. diff --git a/Rakefile b/Rakefile index 68b7e181..2e8fd914 100644 --- a/Rakefile +++ b/Rakefile @@ -24,6 +24,7 @@ def apply_spec_defaults(s) s.add_development_dependency("bacon",">=1.1.0") s.homepage = "http://banisterfiend.wordpress.com" s.has_rdoc = 'yard' + s.executables = ["pry"] s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb", "examples/**/*.rb", "test/*.rb", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile", ".gemtest"] end diff --git a/bin/pry b/bin/pry new file mode 100644 index 00000000..6d2f0d18 --- /dev/null +++ b/bin/pry @@ -0,0 +1,63 @@ +#!/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 => 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| + options[:context] = Pry.binding_for(eval(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] + +# execute line of code, if provided with -e option +options[:context].eval(options[:code]) if options[:code] + +# start the session +options[:context].pry diff --git a/lib/pry/commands.rb b/lib/pry/commands.rb index 7a15d92e..ff64c582 100644 --- a/lib/pry/commands.rb +++ b/lib/pry/commands.rb @@ -465,6 +465,25 @@ e.g: show-method hello_method end end + command "east-coker", "" do + text = %{ +-- +Now the light falls +Across the open field, leaving the deep lane +Shuttered with branches, dark in the afternoon, +Where you lean against a bank while a van passes, +And the deep lane insists on the direction +Into the village, in the electric heat +Hypnotised. In a warm haze the sultry light +Is absorbed, not refracted, by grey stone. +The dahlias sleep in the empty silence. +Wait for the early owl. +-- T.S Eliot +} + output.puts text + text + end + command "cohen-poem", "" do text = %{ -- diff --git a/lib/pry/version.rb b/lib/pry/version.rb index 6bfe091c..97826ede 100644 --- a/lib/pry/version.rb +++ b/lib/pry/version.rb @@ -1,3 +1,3 @@ class Pry - VERSION = "0.5.6" + VERSION = "0.5.7" end