54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/command/update.rb', line 54
def execute(argv)
super
mistook_count = 0
update_target_list = argv.dup
no_open = false
if update_target_list.empty?
Database.instance.each_key do |id|
update_target_list << id
end
no_open = true
end
tagname_to_ids(update_target_list)
update_log = $stdout.capture(quiet: false) do
update_target_list.each_with_index do |target, i|
display_message = nil
data = Downloader.get_data_by_target(target)
if !data
display_message = "<bold><red>[ERROR]</red></bold> #{target} は管理小説の中に存在しません".termcolor
elsif Narou.novel_frozen?(target)
if argv.length > 0
display_message = "ID:#{data["id"]} #{data["title"]} は凍結中です"
else
next
end
end
Helper.print_horizontal_rule if i > 0
if display_message
puts display_message
mistook_count += 1
next
end
result = Downloader.start(target)
case result.status
when :ok
unless @options["no-convert"] ||
(@options["convert-only-new-arrival"] && !result.new_arrivals)
convert_argv = [target]
convert_argv << "--no-open" if no_open
Convert.execute!(convert_argv)
end
when :failed
puts "ID:#{data["id"]} #{data["title"]} の更新は失敗しました"
mistook_count += 1
when :canceled
puts "ID:#{data["id"]} #{data["title"]} の更新はキャンセルされました"
mistook_count += 1
when :none
puts "#{data["title"]} に更新はありません"
end
end
end
save_log(update_log)
exit mistook_count if mistook_count > 0
rescue Interrupt
puts "アップデートを中断しました"
exit Narou::EXIT_ERROR_CODE
end
|