mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Add edit --in (Issue 275)
(Really just testing travis :p)
This commit is contained in:
parent
d319e08a29
commit
bf3243f8f9
2 changed files with 9 additions and 1 deletions
|
@ -115,13 +115,14 @@ class Pry
|
||||||
command "edit", "Invoke the default editor on a file. Type `edit --help` for more info" do |*args|
|
command "edit", "Invoke the default editor on a file. Type `edit --help` for more info" do |*args|
|
||||||
opts = Slop.parse!(args) do |opt|
|
opts = Slop.parse!(args) do |opt|
|
||||||
opt.banner unindent <<-USAGE
|
opt.banner unindent <<-USAGE
|
||||||
Usage: edit [--no-reload|--reload] [--line LINE] [--temp|--ex|FILE[:LINE]]
|
Usage: edit [--no-reload|--reload] [--line LINE] [--temp|--ex|FILE[:LINE]|--in N]
|
||||||
Open a text editor. When no FILE is given, edits the pry input buffer.
|
Open a text editor. When no FILE is given, edits the pry input buffer.
|
||||||
Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.
|
Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.
|
||||||
e.g: edit sample.rb
|
e.g: edit sample.rb
|
||||||
USAGE
|
USAGE
|
||||||
|
|
||||||
opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)", :optional => true, :as => Integer
|
opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)", :optional => true, :as => Integer
|
||||||
|
opt.on :i, :in, "Open a temporary file containing the specified line of _in_.", :optional => true, :as => Integer
|
||||||
opt.on :t, :temp, "Open an empty temporary file"
|
opt.on :t, :temp, "Open an empty temporary file"
|
||||||
opt.on :l, :line, "Jump to this line in the opened file", true, :as => Integer
|
opt.on :l, :line, "Jump to this line in the opened file", true, :as => Integer
|
||||||
opt.on :n, :"no-reload", "Don't automatically reload the edited code"
|
opt.on :n, :"no-reload", "Don't automatically reload the edited code"
|
||||||
|
@ -141,6 +142,8 @@ class Pry
|
||||||
|
|
||||||
content = if opts.t?
|
content = if opts.t?
|
||||||
""
|
""
|
||||||
|
elsif opts.i?
|
||||||
|
_pry_.input_array[opts[:i] || -1] || ""
|
||||||
elsif eval_string.strip != ""
|
elsif eval_string.strip != ""
|
||||||
eval_string
|
eval_string
|
||||||
else
|
else
|
||||||
|
|
|
@ -211,6 +211,11 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
}
|
}
|
||||||
mock_pry("edit -n").should.not =~ /FOO/
|
mock_pry("edit -n").should.not =~ /FOO/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should edit the nth line of _in_" do
|
||||||
|
mock_pry("10", "11", "edit --in -2")
|
||||||
|
@contents.should == "10\n"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue