redmine-backporter.rb: try Readline

* tool/redmine-backporter.rb (readline): try Readline.readline if
  available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-01-20 04:09:24 +00:00
parent 87bb3275aa
commit aa6b7b0701
1 changed files with 9 additions and 3 deletions

View File

@ -8,6 +8,12 @@ require 'stringio'
require 'strscan' require 'strscan'
require 'optparse' require 'optparse'
require 'pp' require 'pp'
begin
require 'readline'
rescue LoadError
else
include Readline
end
VERSION = '0.0.1' VERSION = '0.0.1'
@ -195,7 +201,7 @@ def more(sio)
end end
end end
def readline(prompt = '') def Readline.readline(prompt = '')
console = IO.console console = IO.console
console.binmode console.binmode
ly, lx = console.winsize ly, lx = console.winsize
@ -226,7 +232,7 @@ def readline(prompt = '')
line << c line << c
end end
end end
end end unless defined?(Readline.readline)
def mergeinfo def mergeinfo
`svn propget svn:mergeinfo #{RUBY_REPO_PATH}` `svn propget svn:mergeinfo #{RUBY_REPO_PATH}`
@ -266,7 +272,7 @@ puts "Backporter #{VERSION}".color(bold: true) + " for #{TARGET_VERSION}"
@changesets = nil @changesets = nil
while true while true
begin begin
l = readline '> ' l = Readline.readline '> '
rescue Interrupt rescue Interrupt
break break
end end