1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

improve the 'cat' command

* Ensure that `cat --ex N` sets bt_index to N so that successive --ex progress from that point.
* Prevent cat from breaking on unrecognized file types, and add .prytheme as a YAML file type
This commit is contained in:
John Mair 2012-07-03 00:53:38 +12:00
parent 792d76ab41
commit 0f4adbe976

View file

@ -190,6 +190,8 @@ class Pry
ex.inc_bt_index ex.inc_bt_index
else else
bt_index = opts[:ex] bt_index = opts[:ex]
ex.bt_index = bt_index
ex.inc_bt_index
end end
ex_file, ex_line = ex.bt_source_location_for(bt_index) ex_file, ex_line = ex.bt_source_location_for(bt_index)
@ -256,7 +258,7 @@ class Pry
code = yield(Pry::Code.from_file(file_name)) code = yield(Pry::Code.from_file(file_name))
code.code_type = detect_code_type_from_file(file_name) code.code_type = opts[:type] || detect_code_type_from_file(file_name)
if line_num if line_num
code = code.around(line_num.to_i, code = code.around(line_num.to_i,
Pry.config.default_window_size || 7) Pry.config.default_window_size || 7)
@ -276,17 +278,25 @@ class Pry
:ruby :ruby
when "js" when "js"
return :javascript return :javascript
when "yml" when "yml", "prytheme"
:yaml :yaml
when "groovy"
:groovy
when "c"
:c
when "cpp"
:cpp
when "java"
:java
else else
ext.to_sym :text
end end
else else
case name case name
when "Rakefile", "Gemfile" when "Rakefile", "Gemfile"
:ruby :ruby
else else
:plain :text
end end
end end
end end