Skip to content

Commit

Permalink
fixes #12 差分確認の直後にファイルリストが表示されないように修正。
Browse files Browse the repository at this point in the history
Ctrl-Cで止めたときにRubyのエラー出力が出ないように修正。
  • Loading branch information
tkusukawa committed Aug 10, 2013
1 parent b93f7ff commit ff782e8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/yggdrasil.rb
Expand Up @@ -156,10 +156,18 @@ def select_updates(updates, target_paths)
end

def confirm_updates(updates, yes_no=%w{Y n})
Signal.trap('INT') {
puts
exit 1
}
display_list = true
until @options.has_key?(:non_interactive?)
puts
(0...updates.size).each do |i|
puts "#{i}:#{updates[i][0]} #{updates[i][1]}"
if display_list
(0...updates.size).each do |i|
puts "#{i}:#{updates[i][0]} #{updates[i][1]}"
end
display_list = false
end
print "OK? [#{yes_no[0]}|#{yes_no[1]}|<num to diff>]: "
res = $stdin.gets
Expand All @@ -168,9 +176,10 @@ def confirm_updates(updates, yes_no=%w{Y n})
res.chomp!
break if res == yes_no[0]
return nil if res == yes_no[1]
next unless updates[res.to_i]
if /^\d+$/ =~ res
if /^\d+$/ =~ res && updates[res.to_i]
yield updates[res.to_i][1]
else
display_list = true
end
end
# res == 'Y'
Expand Down

0 comments on commit ff782e8

Please sign in to comment.