mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
added first stab at amend-line, works to modify previous line in eval_string, also added more file types to Rakefile clean task
This commit is contained in:
parent
f0c73cacab
commit
933ce7b355
2 changed files with 11 additions and 2 deletions
3
Rakefile
3
Rakefile
|
@ -5,7 +5,8 @@ $:.unshift 'lib'
|
|||
require 'pry/version'
|
||||
|
||||
CLOBBER.include("**/*~", "**/*#*", "**/*.log")
|
||||
CLEAN.include("**/*#*", "**/*#*.*", "**/*_flymake*.*", "**/*_flymake", "**/*.rbc")
|
||||
CLEAN.include("**/*#*", "**/*#*.*", "**/*_flymake*.*", "**/*_flymake",
|
||||
"**/*.rbc", "**/.#*.*")
|
||||
|
||||
def apply_spec_defaults(s)
|
||||
s.name = "pry"
|
||||
|
|
|
@ -8,6 +8,14 @@ class Pry
|
|||
opts[:eval_string].clear
|
||||
end
|
||||
|
||||
command "amend-line", "Amend the previous line of input." do |replacement_line|
|
||||
replacement_line = "" if !replacement_line
|
||||
input_array = opts[:eval_string].each_line.to_a[0..-2] + [remove_first_word(opts[:val]) + "\n"]
|
||||
opts[:eval_string].replace input_array.join("\n")
|
||||
end
|
||||
|
||||
alias_command "%", "amend-line"
|
||||
|
||||
command "hist", "Show and replay Readline history. Type `hist --help` for more info." do |*args|
|
||||
history = Readline::HISTORY.to_a
|
||||
|
||||
|
@ -17,7 +25,7 @@ class Pry
|
|||
opt.on :g, :grep, 'A pattern to match against the history.', true do |pattern|
|
||||
pattern = Regexp.new pattern
|
||||
history.pop
|
||||
|
||||
|
||||
history.each_with_index do |element, index|
|
||||
if element =~ pattern
|
||||
output.puts "#{colorize index}: #{element}"
|
||||
|
|
Loading…
Reference in a new issue