1
0
Fork 0
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:
John Mair 2011-05-05 22:06:56 +12:00
parent f0c73cacab
commit 933ce7b355
2 changed files with 11 additions and 2 deletions

View file

@ -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"

View file

@ -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}"