gamerom 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/.rubocop.yml +35 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +10 -1
- data/Dockerfile +7 -2
- data/Gemfile +4 -4
- data/Gemfile.lock +4 -4
- data/Makefile +1 -1
- data/README.md +2 -2
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/entrypoint.sh +6 -0
- data/exe/gamerom +2 -1
- data/gamerom.gemspec +22 -22
- data/lib/gamerom.rb +6 -6
- data/lib/gamerom/cli.rb +82 -71
- data/lib/gamerom/config.rb +2 -2
- data/lib/gamerom/game.rb +18 -16
- data/lib/gamerom/game_info.rb +9 -10
- data/lib/gamerom/repo.rb +24 -24
- data/lib/gamerom/repo_adapter.rb +26 -0
- data/lib/gamerom/repo_adapters/coolrom.rb +29 -26
- data/lib/gamerom/repo_adapters/romnation.rb +45 -33
- data/lib/gamerom/repo_adapters/vimm.rb +31 -28
- data/lib/gamerom/version.rb +1 -1
- data/lib/mechanizeprogress.rb +14 -10
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eca8f221edcd2f3f8e311f084c3c4afbf93f642a7e0d4c4731d0af2f758271b7
|
4
|
+
data.tar.gz: 8fb301ca2d507dd9a1000496a7b41a65c5a853a1f29c047525d082eca2ddf548
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b438895a5ca17cb390bc7f7cc49de3f3b730d2eb2ba5ba0cecf0cc5f075b08f1fa5a2f4332c5407c74878d65bcb8e47d8e7a2bd8d2fd454d1f018c6890c53769
|
7
|
+
data.tar.gz: f838766967003016f1830c1ebc80d12540347c3f1e0ed4f7a74df0973afaf0df4a5a1a7c8079f6310949783a0755e5c38ec59568e7cfa1ffad4fe1ebaffe5e35
|
data/.github/workflows/main.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,43 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
|
1
4
|
Style/StringLiterals:
|
2
5
|
Enabled: true
|
3
|
-
EnforcedStyle:
|
6
|
+
EnforcedStyle: single_quotes
|
4
7
|
|
5
8
|
Style/StringLiteralsInInterpolation:
|
6
9
|
Enabled: true
|
7
10
|
EnforcedStyle: double_quotes
|
8
11
|
|
12
|
+
Style/TrailingCommaInHashLiteral:
|
13
|
+
Enabled: false
|
14
|
+
|
9
15
|
Layout/LineLength:
|
10
|
-
Max:
|
16
|
+
Max: 150
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Max: 500
|
20
|
+
|
21
|
+
Metrics/ClassLength:
|
22
|
+
Max: 500
|
23
|
+
|
24
|
+
Metrics/BlockLength:
|
25
|
+
Max: 100
|
26
|
+
|
27
|
+
Metrics/AbcSize:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Metrics/CyclomaticComplexity:
|
31
|
+
Enabled: true
|
32
|
+
Exclude:
|
33
|
+
- 'lib/mechanizeprogress.rb'
|
34
|
+
|
35
|
+
Metrics/PerceivedComplexity:
|
36
|
+
Enabled: true
|
37
|
+
Exclude:
|
38
|
+
- 'lib/mechanizeprogress.rb'
|
39
|
+
|
40
|
+
Style/SoleNestedConditional:
|
41
|
+
Enabled: true
|
42
|
+
Exclude:
|
43
|
+
- 'lib/mechanizeprogress.rb'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.0.
|
1
|
+
ruby-3.0.1
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.4.0] - 2021-05-18
|
10
|
+
- Refactor code #2
|
11
|
+
- Fix all rubocop errors/warnings
|
12
|
+
- Run executable inside container as the same userID/groupID than host user
|
13
|
+
- Fix info when game not found
|
14
|
+
- Update to ruby version 3.0.1
|
15
|
+
- Add `--install` option to search command for installing all games from the search results #3
|
16
|
+
|
9
17
|
## [0.3.0] - 2021-05-14
|
10
18
|
- Use progress bar on the update database commands
|
11
19
|
- Add romnation repo
|
@@ -23,7 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
23
31
|
## [0.1.0] - 2021-05-07
|
24
32
|
- Initial release
|
25
33
|
|
26
|
-
[Unreleased]: https://github.com/lucasmundim/gamerom/compare/v0.
|
34
|
+
[Unreleased]: https://github.com/lucasmundim/gamerom/compare/v0.4.0...HEAD
|
35
|
+
[0.4.0]: https://github.com/lucasmundim/gamerom/compare/v0.3.0...v0.4.0
|
27
36
|
[0.3.0]: https://github.com/lucasmundim/gamerom/compare/v0.2.2...v0.3.0
|
28
37
|
[0.2.2]: https://github.com/lucasmundim/gamerom/compare/v0.2.1...v0.2.2
|
29
38
|
[0.2.1]: https://github.com/lucasmundim/gamerom/compare/v0.2.0...v0.2.1
|
data/Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
FROM ruby:3.0.
|
1
|
+
FROM ruby:3.0.1-alpine as build
|
2
2
|
|
3
3
|
RUN apk add --no-cache --virtual .build-deps \
|
4
4
|
build-base \
|
@@ -7,10 +7,15 @@ RUN apk add --no-cache --virtual .build-deps \
|
|
7
7
|
# throw errors if Gemfile has been modified since Gemfile.lock
|
8
8
|
RUN bundle config --global frozen 1
|
9
9
|
|
10
|
+
RUN mkdir -p /bundle && chmod 777 /bundle
|
11
|
+
|
12
|
+
ENV GEM_HOME="/bundle"
|
13
|
+
ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
|
14
|
+
|
10
15
|
RUN mkdir -p /app
|
11
16
|
WORKDIR /app
|
12
17
|
|
13
18
|
COPY . .
|
14
19
|
RUN bundle install
|
15
20
|
|
16
|
-
ENTRYPOINT ["
|
21
|
+
ENTRYPOINT ["/app/entrypoint.sh"]
|
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in gamerom.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
8
|
+
gem 'rake', '~> 13.0'
|
9
9
|
|
10
|
-
gem
|
10
|
+
gem 'rspec', '~> 3.0'
|
11
11
|
|
12
|
-
gem
|
12
|
+
gem 'rubocop', '~> 0.80'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gamerom (0.
|
4
|
+
gamerom (0.4.0)
|
5
5
|
mechanize (~> 2.8.0)
|
6
6
|
mechanize-progressbar (~> 0.2.0)
|
7
7
|
nokogiri (~> 1.11.3)
|
@@ -43,9 +43,9 @@ GEM
|
|
43
43
|
net-http-persistent (4.0.1)
|
44
44
|
connection_pool (~> 2.2)
|
45
45
|
netrc (0.11.0)
|
46
|
-
nokogiri (1.11.
|
46
|
+
nokogiri (1.11.4-x86_64-darwin)
|
47
47
|
racc (~> 1.4)
|
48
|
-
nokogiri (1.11.
|
48
|
+
nokogiri (1.11.4-x86_64-linux)
|
49
49
|
racc (~> 1.4)
|
50
50
|
parallel (1.20.1)
|
51
51
|
parser (3.0.1.0)
|
@@ -107,4 +107,4 @@ DEPENDENCIES
|
|
107
107
|
rubocop (~> 0.80)
|
108
108
|
|
109
109
|
BUNDLED WITH
|
110
|
-
2.2.
|
110
|
+
2.2.15
|
data/Makefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
VERSION:=$(shell cat lib/gamerom/version.rb |grep VERSION|cut -d\
|
1
|
+
VERSION:=$(shell cat lib/gamerom/version.rb |grep VERSION|cut -d\' -f2)
|
2
2
|
IMAGE=lucasmundim/gamerom:${VERSION}
|
3
3
|
DOCKER_OPTS=--rm -it -v ${HOME}/.gamerom:/root/.gamerom ${IMAGE}
|
4
4
|
LOCAL_VOLUME_OPTS=-v ${CURDIR}:/app
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ It currently supports the following repositories:
|
|
15
15
|
Add this to your .bashrc, .bash_aliases, etc:
|
16
16
|
|
17
17
|
```
|
18
|
-
alias gamerom=
|
18
|
+
alias gamerom="docker run -e UID=$(id -u) -e GROUP_ID=$(id -g) --rm -it -v ~/.gamerom:/home/runuser/.gamerom docker.io/lucasmundim/gamerom:0.4.0"
|
19
19
|
```
|
20
20
|
|
21
21
|
Use it as:
|
@@ -585,7 +585,7 @@ Print program version
|
|
585
585
|
|
586
586
|
```
|
587
587
|
$ gamerom version
|
588
|
-
0.
|
588
|
+
0.4.0
|
589
589
|
```
|
590
590
|
|
591
591
|
## Development
|
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,40 +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
|
36
|
-
spec.add_runtime_dependency
|
37
|
-
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'
|
38
38
|
|
39
39
|
# For more information and examples about making a new gem, checkout our
|
40
40
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/gamerom.rb
CHANGED
@@ -1,11 +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
|
8
|
-
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'
|
9
9
|
|
10
10
|
module Gamerom
|
11
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.filenames 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
|
265
273
|
puts "updating all databases on #{options[:repo]} repo..."
|
266
274
|
repo = Repo.new(options[:repo])
|
267
|
-
repo.platforms.
|
275
|
+
repo.platforms.each_key do |platform|
|
268
276
|
repo = Repo.new(options[:repo])
|
269
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,21 +312,23 @@ module Gamerom
|
|
303
312
|
game.name,
|
304
313
|
game.region,
|
305
314
|
game.installed? ? shell.set_color('installed', :green) : '-',
|
306
|
-
game.respond_to?(:tags) ? game.tags.join(
|
315
|
+
game.respond_to?(:tags) ? game.tags.join(', ') : '-'
|
307
316
|
]
|
308
317
|
end
|
309
318
|
results.sort_by! { |columns| columns[1] }
|
310
|
-
results.unshift [
|
319
|
+
results.unshift %w[ID NAME REGION INSTALLED TAGS]
|
311
320
|
shell.print_table(results)
|
312
321
|
end
|
313
322
|
|
314
|
-
def render_error
|
323
|
+
def render_error(exception, options)
|
315
324
|
shell.say exception.message, :red
|
316
325
|
shell.say exception.full_message.force_encoding('utf-8'), :red if options[:verbose]
|
317
326
|
end
|
318
327
|
|
319
328
|
def validate_platform(repo, platform)
|
320
|
-
|
329
|
+
return if repo.platforms.keys.include? options[:platform]
|
330
|
+
|
331
|
+
raise "Expected '--platform' to be one of #{repo.platforms.keys.join(", ")}; got #{platform}"
|
321
332
|
end
|
322
333
|
end
|
323
334
|
end
|