gamerom 0.1.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/.rubocop.yml +35 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +40 -0
- data/Dockerfile +7 -2
- data/Gemfile +4 -4
- data/Gemfile.lock +11 -5
- data/Makefile +1 -1
- data/README.md +117 -71
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/entrypoint.sh +6 -0
- data/exe/gamerom +2 -1
- data/gamerom.gemspec +22 -20
- data/lib/gamerom.rb +6 -5
- data/lib/gamerom/cli.rb +85 -73
- data/lib/gamerom/config.rb +2 -2
- data/lib/gamerom/game.rb +23 -14
- data/lib/gamerom/game_info.rb +93 -0
- data/lib/gamerom/repo.rb +24 -25
- data/lib/gamerom/repo_adapter.rb +26 -0
- data/lib/gamerom/repo_adapters/coolrom.rb +38 -31
- data/lib/gamerom/repo_adapters/romnation.rb +110 -0
- data/lib/gamerom/repo_adapters/vimm.rb +50 -25
- data/lib/gamerom/version.rb +1 -1
- data/lib/mechanizeprogress.rb +48 -0
- metadata +39 -5
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
require
|
8
|
+
require 'rubocop/rake_task'
|
9
9
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
|
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'gamerom'
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require "gamerom"
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require 'irb'
|
15
15
|
IRB.start(__FILE__)
|
data/entrypoint.sh
ADDED
data/exe/gamerom
CHANGED
data/gamerom.gemspec
CHANGED
@@ -1,38 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/gamerom/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'gamerom'
|
7
7
|
spec.version = Gamerom::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ['Lucas Mundim']
|
9
|
+
spec.email = ['lucas.mundim@gmail.com']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
11
|
+
spec.summary = 'The Video Game ROM downloader'
|
12
|
+
spec.description = 'A command-line installer for game ROMs from many repositories.'
|
13
|
+
spec.homepage = 'https://github.com/lucasmundim/gamerom'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.0.1')
|
16
16
|
|
17
|
-
spec.metadata[
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
18
|
|
19
|
-
spec.metadata[
|
20
|
-
spec.metadata[
|
21
|
-
spec.metadata[
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
21
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
27
|
end
|
28
|
-
spec.bindir =
|
28
|
+
spec.bindir = 'exe'
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = [
|
31
|
-
|
32
|
-
spec.add_runtime_dependency
|
33
|
-
spec.add_runtime_dependency
|
34
|
-
spec.add_runtime_dependency
|
35
|
-
spec.add_runtime_dependency
|
30
|
+
spec.require_paths = ['lib']
|
31
|
+
|
32
|
+
spec.add_runtime_dependency 'mechanize', '~> 2.8.0'
|
33
|
+
spec.add_runtime_dependency 'mechanize-progressbar', '~> 0.2.0'
|
34
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.11.3'
|
35
|
+
spec.add_runtime_dependency 'progressbar', '~> 0.9.0'
|
36
|
+
spec.add_runtime_dependency 'rest-client', '~> 2.1.0'
|
37
|
+
spec.add_runtime_dependency 'thor', '~> 1.1.0'
|
36
38
|
|
37
39
|
# For more information and examples about making a new gem, checkout our
|
38
40
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/gamerom.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
3
|
+
require_relative 'gamerom/config'
|
4
|
+
require_relative 'gamerom/game'
|
5
|
+
require_relative 'gamerom/game_info'
|
6
|
+
require_relative 'gamerom/repo'
|
7
|
+
require_relative 'gamerom/cli'
|
8
|
+
require_relative 'gamerom/version'
|
8
9
|
|
9
10
|
module Gamerom
|
10
11
|
class Error < StandardError; end
|
data/lib/gamerom/cli.rb
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
require 'thor'
|
4
4
|
|
5
5
|
module Gamerom
|
6
|
+
# Cli - Main cli commands
|
6
7
|
class Cli < Thor
|
7
|
-
class_option :verbose, :
|
8
|
+
class_option :verbose, aliases: ['-v'], type: :boolean, default: false, desc: 'Show verbose backtrace'
|
8
9
|
|
9
10
|
def self.exit_on_failure?
|
10
11
|
true
|
@@ -22,26 +23,27 @@ module Gamerom
|
|
22
23
|
end
|
23
24
|
|
24
25
|
desc 'info GAME_IDENTIFIER', 'Info for game GAME_IDENTIFIER (id/name)'
|
25
|
-
option :repo, :
|
26
|
-
option :platform, :
|
26
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
27
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
27
28
|
def info(game_identifier)
|
28
29
|
repo = Repo.new(options[:repo])
|
29
30
|
validate_platform repo, options[:platform]
|
30
31
|
puts "showing info for game #{game_identifier} on #{options[:platform]} platform on #{options[:repo]} repo..."
|
31
32
|
game = repo.find(options[:platform], game_identifier)
|
32
|
-
if game.nil?
|
33
|
+
if !game.nil?
|
34
|
+
puts game
|
35
|
+
puts game.filenames if game.installed?
|
36
|
+
else
|
33
37
|
shell.say "Game #{game_identifier} not found", :red
|
34
38
|
end
|
35
|
-
|
36
|
-
puts game.filename if game.installed?
|
37
|
-
rescue => e
|
39
|
+
rescue StandardError => e
|
38
40
|
render_error e, options
|
39
41
|
exit 1
|
40
42
|
end
|
41
43
|
|
42
44
|
desc 'install GAME_IDENTIFIER', 'Install game GAME_IDENTIFIER (id/name)'
|
43
|
-
option :repo, :
|
44
|
-
option :platform, :
|
45
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
46
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
45
47
|
def install(game_identifier)
|
46
48
|
repo = Repo.new(options[:repo])
|
47
49
|
validate_platform repo, options[:platform]
|
@@ -52,20 +54,20 @@ module Gamerom
|
|
52
54
|
end
|
53
55
|
puts "installing game #{game.id} - #{game.name} - #{game.region} on #{options[:platform]} platform on #{options[:repo]} repo..."
|
54
56
|
if game.installed?
|
55
|
-
shell.say
|
57
|
+
shell.say 'Game already installed', :yellow
|
56
58
|
return
|
57
59
|
end
|
58
60
|
game.install
|
59
|
-
shell.say
|
60
|
-
rescue => e
|
61
|
+
shell.say 'Game installed', :green
|
62
|
+
rescue StandardError => e
|
61
63
|
render_error e, options
|
62
64
|
exit 1
|
63
65
|
end
|
64
66
|
|
65
67
|
desc 'install_all', 'Install all games'
|
66
|
-
option :repo, :
|
67
|
-
option :platform, :
|
68
|
-
option :region, :
|
68
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
69
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
70
|
+
option :region, aliases: ['-g'], type: :string, required: false, desc: 'Only from specified region'
|
69
71
|
def install_all
|
70
72
|
repo = Repo.new(options[:repo])
|
71
73
|
validate_platform repo, options[:platform]
|
@@ -73,40 +75,40 @@ module Gamerom
|
|
73
75
|
games.each do |game|
|
74
76
|
install(game.id) unless game.installed?
|
75
77
|
end
|
76
|
-
rescue => e
|
78
|
+
rescue StandardError => e
|
77
79
|
render_error e, options
|
78
80
|
exit 1
|
79
81
|
end
|
80
82
|
|
81
83
|
desc 'list', 'List available games'
|
82
|
-
option :repo, :
|
83
|
-
option :platform, :
|
84
|
-
option :region, :
|
84
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
85
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
86
|
+
option :region, aliases: ['-g'], type: :string, required: false, desc: 'Only from specified region'
|
85
87
|
def list
|
86
88
|
repo = Repo.new(options[:repo])
|
87
89
|
validate_platform repo, options[:platform]
|
88
90
|
puts "listing available games for #{options[:platform]} platform on #{options[:repo]} repo..."
|
89
91
|
games = repo.games options[:platform], region: options[:region]
|
90
92
|
print_game_table(games)
|
91
|
-
rescue => e
|
93
|
+
rescue StandardError => e
|
92
94
|
render_error e, options
|
93
95
|
exit 1
|
94
96
|
end
|
95
97
|
|
96
98
|
desc 'platforms', 'List available platforms'
|
97
|
-
option :repo, :
|
99
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
98
100
|
def platforms
|
99
101
|
puts "listing available platforms for #{options[:repo]} repo..."
|
100
102
|
platforms = { platforms: Repo.new(options[:repo]).platforms }
|
101
103
|
puts platforms.to_yaml
|
102
|
-
rescue => e
|
104
|
+
rescue StandardError => e
|
103
105
|
render_error e, options
|
104
106
|
exit 1
|
105
107
|
end
|
106
108
|
|
107
109
|
desc 'recover', 'Try to recover state from already downloaded roms'
|
108
|
-
option :repo, :
|
109
|
-
option :platform, :
|
110
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
111
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
110
112
|
def recover
|
111
113
|
repo = Repo.new(options[:repo])
|
112
114
|
validate_platform repo, options[:platform]
|
@@ -116,10 +118,9 @@ module Gamerom
|
|
116
118
|
games.each do |game|
|
117
119
|
filename = nil
|
118
120
|
basename = "#{Gamerom::GAME_DIR}/#{repo.name}/#{options[:platform]}/#{game[:region]}/#{game[:name]}"
|
119
|
-
[
|
120
|
-
|
121
|
-
|
122
|
-
end
|
121
|
+
%w[zip 7z rar].each do |ext|
|
122
|
+
fullname = "#{basename}.#{ext}"
|
123
|
+
filename = fullname if File.exist? fullname
|
123
124
|
end
|
124
125
|
|
125
126
|
if filename
|
@@ -129,100 +130,107 @@ module Gamerom
|
|
129
130
|
games_not_found << game[:name]
|
130
131
|
end
|
131
132
|
end
|
132
|
-
if games_not_found.count
|
133
|
-
puts
|
133
|
+
if games_not_found.count.positive?
|
134
|
+
puts 'Games not found:'
|
134
135
|
puts games_not_found
|
135
136
|
end
|
136
|
-
rescue => e
|
137
|
+
rescue StandardError => e
|
137
138
|
puts e.message
|
138
139
|
exit 1
|
139
140
|
end
|
140
141
|
|
141
142
|
desc 'regions', 'List available regions'
|
142
|
-
option :repo, :
|
143
|
-
option :platform, :
|
143
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
144
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
144
145
|
def regions
|
145
146
|
repo = Repo.new(options[:repo])
|
146
147
|
validate_platform repo, options[:platform]
|
147
148
|
puts "listing available regions for #{options[:platform]} platform on #{options[:repo]} repo..."
|
148
149
|
puts repo.regions options[:platform]
|
149
|
-
rescue => e
|
150
|
+
rescue StandardError => e
|
150
151
|
render_error e, options
|
151
152
|
exit 1
|
152
153
|
end
|
153
154
|
|
154
155
|
desc 'repo', 'List available repo'
|
155
156
|
def repo
|
156
|
-
puts
|
157
|
+
puts 'listing available repo...'
|
157
158
|
puts Repo.list
|
158
|
-
rescue => e
|
159
|
+
rescue StandardError => e
|
159
160
|
render_error e, options
|
160
161
|
exit 1
|
161
162
|
end
|
162
163
|
|
163
164
|
desc 'search KEYWORD', 'Search games by KEYWORD'
|
164
|
-
option :repo, :
|
165
|
-
option :platform, :
|
166
|
-
option :region, :
|
165
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
166
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
167
|
+
option :region, aliases: ['-g'], type: :string, required: false, desc: 'Only from specified region'
|
168
|
+
option :install, aliases: ['-I'], type: :boolean, required: false, desc: 'Install search results'
|
167
169
|
def search(keyword)
|
168
170
|
repo = Repo.new(options[:repo])
|
169
171
|
validate_platform repo, options[:platform]
|
170
172
|
puts "searching available games for #{options[:platform]} platform on #{options[:repo]} repo..."
|
171
173
|
games = repo.games options[:platform], region: options[:region], keyword: keyword
|
172
|
-
|
173
|
-
|
174
|
+
if options[:install]
|
175
|
+
games.each do |game|
|
176
|
+
install(game.id) unless game.installed?
|
177
|
+
end
|
178
|
+
else
|
179
|
+
print_game_table(games)
|
180
|
+
end
|
181
|
+
rescue StandardError => e
|
174
182
|
render_error e, options
|
175
183
|
exit 1
|
176
184
|
end
|
177
185
|
|
178
186
|
desc 'stats', 'Show platform stats'
|
179
|
-
option :repo, :
|
180
|
-
option :platform, :
|
187
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
188
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
181
189
|
def stats
|
182
190
|
repo = Repo.new(options[:repo])
|
183
191
|
validate_platform repo, options[:platform]
|
184
192
|
puts "stats for #{options[:platform]} platform on #{options[:repo]} repo..."
|
185
193
|
games = repo.games options[:platform]
|
186
194
|
total = games.count
|
187
|
-
installed = games.select
|
195
|
+
installed = games.select(&:installed?).count
|
188
196
|
size = 0
|
189
|
-
if File.
|
197
|
+
if File.exist? "#{Gamerom::GAME_DIR}/#{repo.name}/#{options[:platform]}"
|
190
198
|
size = `du -hs "#{Gamerom::GAME_DIR}/#{repo.name}/#{options[:platform]}/"|awk '{ print $1 }'`
|
191
199
|
end
|
192
200
|
puts " All: #{installed}/#{total} - size: #{size}"
|
193
201
|
repo.regions(options[:platform]).each do |region|
|
194
202
|
games = repo.games(options[:platform], region: region)
|
195
203
|
total = games.count
|
196
|
-
installed = games.select
|
204
|
+
installed = games.select(&:installed?).count
|
197
205
|
size = 0
|
198
|
-
if File.
|
206
|
+
if File.exist? "#{Gamerom::GAME_DIR}/#{repo.name}/#{options[:platform]}/#{region}"
|
199
207
|
size = `du -hs "#{Gamerom::GAME_DIR}/#{repo.name}/#{options[:platform]}/#{region}/"|awk '{ print $1 }'`
|
200
208
|
end
|
201
209
|
puts " #{region}: #{installed}/#{total} - size: #{size}"
|
202
210
|
end
|
203
211
|
puts
|
204
|
-
rescue => e
|
212
|
+
rescue StandardError => e
|
205
213
|
render_error e, options
|
206
214
|
exit 1
|
207
215
|
end
|
208
216
|
|
209
217
|
desc 'stats_all', 'Show stats for all platforms'
|
210
|
-
option :repo, :
|
218
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
211
219
|
def stats_all
|
212
220
|
repo = Repo.new(options[:repo])
|
213
|
-
repo.platforms.
|
221
|
+
repo.platforms.each_key do |platform|
|
214
222
|
a = Gamerom::Cli.new
|
215
223
|
a.options = { platform: platform, repo: options[:repo] }
|
216
224
|
a.stats
|
217
225
|
end
|
218
|
-
rescue => e
|
226
|
+
rescue StandardError => e
|
219
227
|
render_error e, options
|
220
228
|
exit 1
|
221
229
|
end
|
222
230
|
|
223
231
|
desc 'uninstall GAME_IDENTIFIER', 'Uninstall game GAME_IDENTIFIER (id/name)'
|
224
|
-
option :repo, :
|
225
|
-
option :platform, :
|
232
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
233
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
226
234
|
def uninstall(game_identifier)
|
227
235
|
repo = Repo.new(options[:repo])
|
228
236
|
validate_platform repo, options[:platform]
|
@@ -232,21 +240,21 @@ module Gamerom
|
|
232
240
|
return
|
233
241
|
end
|
234
242
|
puts "uninstalling game #{game.id} - #{game.name} - #{game.region} on #{options[:platform]} platform..."
|
235
|
-
|
236
|
-
shell.say
|
243
|
+
unless game.installed?
|
244
|
+
shell.say 'Game is not installed', :yellow
|
237
245
|
return
|
238
246
|
end
|
239
247
|
game.uninstall
|
240
|
-
shell.say
|
241
|
-
rescue => e
|
248
|
+
shell.say 'Game uninstalled', :green
|
249
|
+
rescue StandardError => e
|
242
250
|
render_error e, options
|
243
251
|
exit 1
|
244
252
|
end
|
245
253
|
|
246
254
|
desc 'uninstall_all', 'Uninstall all games'
|
247
|
-
option :repo, :
|
248
|
-
option :platform, :
|
249
|
-
option :region, :
|
255
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
256
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
257
|
+
option :region, aliases: ['-g'], type: :string, required: false, desc: 'Only from specified region'
|
250
258
|
def uninstall_all
|
251
259
|
repo = Repo.new(options[:repo])
|
252
260
|
validate_platform repo, options[:platform]
|
@@ -254,36 +262,36 @@ module Gamerom
|
|
254
262
|
games.each do |game|
|
255
263
|
uninstall(game.id) if game.installed?
|
256
264
|
end
|
257
|
-
rescue => e
|
265
|
+
rescue StandardError => e
|
258
266
|
render_error e, options
|
259
267
|
exit 1
|
260
268
|
end
|
261
269
|
|
262
270
|
desc 'update_all_databases', 'Update all local databases'
|
263
|
-
option :repo, :
|
271
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
264
272
|
def update_all_databases
|
273
|
+
puts "updating all databases on #{options[:repo]} repo..."
|
265
274
|
repo = Repo.new(options[:repo])
|
266
|
-
repo.platforms.
|
267
|
-
|
268
|
-
|
269
|
-
a.update_database
|
275
|
+
repo.platforms.each_key do |platform|
|
276
|
+
repo = Repo.new(options[:repo])
|
277
|
+
repo.update_database platform
|
270
278
|
end
|
271
279
|
shell.say 'All game databases updated', :green
|
272
|
-
rescue => e
|
280
|
+
rescue StandardError => e
|
273
281
|
render_error e, options
|
274
282
|
exit 1
|
275
283
|
end
|
276
284
|
|
277
285
|
desc 'update_database', 'Update local database'
|
278
|
-
option :repo, :
|
279
|
-
option :platform, :
|
286
|
+
option :repo, aliases: ['-r'], type: :string, required: true, desc: 'Which repo to use', enum: Gamerom::Repo.list.map(&:to_s)
|
287
|
+
option :platform, aliases: ['-p'], type: :string, required: true, desc: 'Which platform to use'
|
280
288
|
def update_database
|
281
289
|
repo = Repo.new(options[:repo])
|
282
290
|
validate_platform repo, options[:platform]
|
283
291
|
puts "updating #{options[:platform]} platform on #{options[:repo]} repo..."
|
284
292
|
repo.update_database options[:platform]
|
285
293
|
shell.say "Game database updated for platform #{options[:platform]} on #{options[:repo]} repo", :green
|
286
|
-
rescue => e
|
294
|
+
rescue StandardError => e
|
287
295
|
render_error e, options
|
288
296
|
exit 1
|
289
297
|
end
|
@@ -294,6 +302,7 @@ module Gamerom
|
|
294
302
|
end
|
295
303
|
|
296
304
|
private
|
305
|
+
|
297
306
|
def print_game_table(games)
|
298
307
|
results = []
|
299
308
|
|
@@ -303,20 +312,23 @@ module Gamerom
|
|
303
312
|
game.name,
|
304
313
|
game.region,
|
305
314
|
game.installed? ? shell.set_color('installed', :green) : '-',
|
315
|
+
game.respond_to?(:tags) ? game.tags.join(', ') : '-'
|
306
316
|
]
|
307
317
|
end
|
308
318
|
results.sort_by! { |columns| columns[1] }
|
309
|
-
results.unshift [
|
319
|
+
results.unshift %w[ID NAME REGION INSTALLED TAGS]
|
310
320
|
shell.print_table(results)
|
311
321
|
end
|
312
322
|
|
313
|
-
def render_error
|
323
|
+
def render_error(exception, options)
|
314
324
|
shell.say exception.message, :red
|
315
325
|
shell.say exception.full_message.force_encoding('utf-8'), :red if options[:verbose]
|
316
326
|
end
|
317
327
|
|
318
328
|
def validate_platform(repo, platform)
|
319
|
-
|
329
|
+
return if repo.platforms.keys.include? options[:platform]
|
330
|
+
|
331
|
+
raise "Expected '--platform' to be one of #{repo.platforms.keys.join(", ")}; got #{platform}"
|
320
332
|
end
|
321
333
|
end
|
322
334
|
end
|