From 506cb40667fa5d5786dad18a21df824d9b2f66c6 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 20 Jan 2015 03:14:21 +0000 Subject: 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 --- tool/redmine-backporter.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tool') diff --git a/tool/redmine-backporter.rb b/tool/redmine-backporter.rb index ea56dc19c2..bda4abcc56 100755 --- a/tool/redmine-backporter.rb +++ b/tool/redmine-backporter.rb @@ -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)) -- cgit v1.2.3