mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
version 0.6.1(pre), added !! as alias for exit-all, added cd/ to return to pry toplevel, improved pry
command line so it uses a rep session on -e code
This commit is contained in:
parent
03ddbba37a
commit
7ce581e7fd
4 changed files with 29 additions and 11 deletions
6
TODO
6
TODO
|
@ -1,3 +1,9 @@
|
||||||
|
0.6.1
|
||||||
|
* !! command alias for exit_all
|
||||||
|
* `cd /` for breaking out to pry top level (jump-to 0)
|
||||||
|
* `less` command? and pipe support?
|
||||||
|
* made `-e` option work in a more effective way for `pry` command line invocation
|
||||||
|
|
||||||
0.5.0 release:
|
0.5.0 release:
|
||||||
* !!!! UPDATE DOCUMENTATION !!!!
|
* !!!! UPDATE DOCUMENTATION !!!!
|
||||||
* Use clipped version of Pry.view() for large objects
|
* Use clipped version of Pry.view() for large objects
|
||||||
|
|
5
bin/pry
5
bin/pry
|
@ -61,10 +61,9 @@ load rcpath if File.exists?(rcpath) && options[:loadrc]
|
||||||
# create the actual context
|
# create the actual context
|
||||||
context = Pry.binding_for(eval(options[:context_string]))
|
context = Pry.binding_for(eval(options[:context_string]))
|
||||||
|
|
||||||
# execute line of code, if provided with -e option
|
# run code passed with `-e`, if there is any.
|
||||||
if options[:code]
|
if options[:code]
|
||||||
result = context.eval(options[:code])
|
Pry.new(:input => StringIO.new(options[:code]), :print => proc {}).rep(context)
|
||||||
puts "=> #{Pry.view(result)}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# start the session
|
# start the session
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
direc = File.dirname(__FILE__)
|
direc = File.dirname(__FILE__)
|
||||||
require "#{direc}/command_base"
|
|
||||||
require "optparse"
|
require "optparse"
|
||||||
|
require "method_source"
|
||||||
|
require "#{direc}/command_base"
|
||||||
|
require "#{direc}/pry_instance"
|
||||||
|
|
||||||
class Pry
|
class Pry
|
||||||
|
|
||||||
|
@ -72,10 +75,12 @@ class Pry
|
||||||
output.puts "Pry version: #{Pry::VERSION} on Ruby #{RUBY_VERSION}."
|
output.puts "Pry version: #{Pry::VERSION} on Ruby #{RUBY_VERSION}."
|
||||||
end
|
end
|
||||||
|
|
||||||
command "exit-all", "End all nested Pry sessions." do
|
command "exit-all", "End all nested Pry sessions. Aliases: !!" do
|
||||||
throw(:breakout, 0)
|
throw(:breakout, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias_command "!!", "exit-all", ""
|
||||||
|
|
||||||
command "ls", "Show the list of vars in the current scope. Type `ls --help` for more info." do |*args|
|
command "ls", "Show the list of vars in the current scope. Type `ls --help` for more info." do |*args|
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
|
@ -210,7 +215,7 @@ Shows local and instance variables by default.
|
||||||
if options[:v]
|
if options[:v]
|
||||||
|
|
||||||
# verbose
|
# verbose
|
||||||
info.each.sort_by { |k, v| v.last }.each do |k, v|
|
info.sort_by { |k, v| v.last }.each do |k, v|
|
||||||
if !v.first.empty?
|
if !v.first.empty?
|
||||||
output.puts "#{k}:\n--"
|
output.puts "#{k}:\n--"
|
||||||
output.puts Pry.view(v.first)
|
output.puts Pry.view(v.first)
|
||||||
|
@ -218,7 +223,7 @@ Shows local and instance variables by default.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# plain
|
# plain
|
||||||
else
|
else
|
||||||
list = info.values.sort_by { |v| v.last }.map { |v| v.first }.inject(&:+)
|
list = info.values.sort_by { |v| v.last }.map { |v| v.first }.inject(&:+)
|
||||||
output.puts Pry.view(list)
|
output.puts Pry.view(list)
|
||||||
|
@ -232,7 +237,9 @@ Shows local and instance variables by default.
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
output.puts File.read(file_name)
|
contents = File.read(file_name)
|
||||||
|
output.puts contents
|
||||||
|
contents
|
||||||
end
|
end
|
||||||
|
|
||||||
command "eval-file", "Eval a Ruby script. Type `eval-file --help` for more info." do |*args|
|
command "eval-file", "Eval a Ruby script. Type `eval-file --help` for more info." do |*args|
|
||||||
|
@ -290,13 +297,19 @@ e.g: eval-file -c self "hello.rb"
|
||||||
|
|
||||||
alias_command "inspect", "cat", ""
|
alias_command "inspect", "cat", ""
|
||||||
|
|
||||||
command "cd", "Start a Pry session on VAR (use `cd ..` to go back)" do |obj|
|
command "cd", "Start a Pry session on VAR (use `cd ..` to go back and `cd /` to return to Pry top-level)" do |obj|
|
||||||
if !obj
|
if !obj
|
||||||
output.puts "Must provide an object."
|
output.puts "Must provide an object."
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
throw(:breakout, opts[:nesting].level) if obj == ".."
|
throw(:breakout, opts[:nesting].level) if obj == ".."
|
||||||
|
|
||||||
|
if obj == "/"
|
||||||
|
throw(:breakout, 1) if opts[:nesting].level > 0
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
target.eval("#{obj}.pry")
|
target.eval("#{obj}.pry")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -515,7 +528,7 @@ on these enormous landscapes,
|
||||||
that if you turn your head
|
that if you turn your head
|
||||||
they are lost for hours.
|
they are lost for hours.
|
||||||
-- Leonard Cohen
|
-- Leonard Cohen
|
||||||
}
|
}
|
||||||
output.puts text
|
output.puts text
|
||||||
text
|
text
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
class Pry
|
class Pry
|
||||||
VERSION = "0.6.0"
|
VERSION = "0.6.1pro1"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue