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

redmine-backporter.rb: like Readline.readline

* tool/redmine-backporter.rb (readline): rename and add optional
  argument prompt, like Readline.readline.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-01-20 03:14:21 +00:00
parent 6cb0b95fe3
commit 506cb40667

View file

@ -195,16 +195,17 @@ def more(sio)
end
end
def mygets
def readline(prompt = '')
console = IO.console
ly, lx = console.winsize
cls = "\r" + (" " * lx) + "\r> "
cls = "\r" + (" " * lx) + "\r" + prompt
console.print prompt
console.flush
line = ''
while 1
case c = console.getch
when "\r", "\n"
puts
line << c
return line
when "\C-?", "\b" # DEL/BS
print "\b \b" if line.chop!
@ -258,13 +259,11 @@ puts "Backporter #{VERSION}".color(bold: true) + " for #{TARGET_VERSION}"
@issue = nil
@changesets = nil
while true
print '> '
begin
l = mygets
l = readline '> '
rescue Interrupt
break
end
l.strip! if l
case l
when 'ls'
uri = URI(REDMINE_BASE+'/projects/ruby-trunk/issues.json?'+URI.encode_www_form(@query))