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:
|
||||
* !!!! UPDATE DOCUMENTATION !!!!
|
||||
* 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
|
||||
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]
|
||||
result = context.eval(options[:code])
|
||||
puts "=> #{Pry.view(result)}"
|
||||
Pry.new(:input => StringIO.new(options[:code]), :print => proc {}).rep(context)
|
||||
end
|
||||
|
||||
# start the session
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
direc = File.dirname(__FILE__)
|
||||
require "#{direc}/command_base"
|
||||
|
||||
require "optparse"
|
||||
require "method_source"
|
||||
require "#{direc}/command_base"
|
||||
require "#{direc}/pry_instance"
|
||||
|
||||
class Pry
|
||||
|
||||
|
@ -72,10 +75,12 @@ class Pry
|
|||
output.puts "Pry version: #{Pry::VERSION} on Ruby #{RUBY_VERSION}."
|
||||
end
|
||||
|
||||
command "exit-all", "End all nested Pry sessions." do
|
||||
command "exit-all", "End all nested Pry sessions. Aliases: !!" do
|
||||
throw(:breakout, 0)
|
||||
end
|
||||
|
||||
alias_command "!!", "exit-all", ""
|
||||
|
||||
command "ls", "Show the list of vars in the current scope. Type `ls --help` for more info." do |*args|
|
||||
options = {}
|
||||
|
||||
|
@ -210,7 +215,7 @@ Shows local and instance variables by default.
|
|||
if options[:v]
|
||||
|
||||
# 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?
|
||||
output.puts "#{k}:\n--"
|
||||
output.puts Pry.view(v.first)
|
||||
|
@ -218,7 +223,7 @@ Shows local and instance variables by default.
|
|||
end
|
||||
end
|
||||
|
||||
# plain
|
||||
# plain
|
||||
else
|
||||
list = info.values.sort_by { |v| v.last }.map { |v| v.first }.inject(&:+)
|
||||
output.puts Pry.view(list)
|
||||
|
@ -232,7 +237,9 @@ Shows local and instance variables by default.
|
|||
next
|
||||
end
|
||||
|
||||
output.puts File.read(file_name)
|
||||
contents = File.read(file_name)
|
||||
output.puts contents
|
||||
contents
|
||||
end
|
||||
|
||||
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", ""
|
||||
|
||||
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
|
||||
output.puts "Must provide an object."
|
||||
next
|
||||
end
|
||||
|
||||
throw(:breakout, opts[:nesting].level) if obj == ".."
|
||||
|
||||
if obj == "/"
|
||||
throw(:breakout, 1) if opts[:nesting].level > 0
|
||||
next
|
||||
end
|
||||
|
||||
target.eval("#{obj}.pry")
|
||||
end
|
||||
|
||||
|
@ -515,7 +528,7 @@ on these enormous landscapes,
|
|||
that if you turn your head
|
||||
they are lost for hours.
|
||||
-- Leonard Cohen
|
||||
}
|
||||
}
|
||||
output.puts text
|
||||
text
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class Pry
|
||||
VERSION = "0.6.0"
|
||||
VERSION = "0.6.1pro1"
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue