Class: Factorix::CLI::Commands::MOD::Download
- Inherits:
-
Base
- Object
- Dry::CLI::Command
- Base
- Factorix::CLI::Commands::MOD::Download
- Includes:
- DownloadSupport, PortalSupport
- Defined in:
- lib/factorix/cli/commands/mod/download.rb,
sig/factorix/cli/commands/mod/download.rbs
Overview
Download MOD files from Factorio MOD Portal
Instance Attribute Summary collapse
-
#logger ⇒ Dry::Logger::Dispatcher
readonly
Returns the value of attribute logger.
-
#portal ⇒ Portal
readonly
Returns the value of attribute portal.
Instance Method Summary collapse
-
#call(mod_specs:, directory: ".", jobs: "4", recursive: false) ⇒ void
Execute the download command.
Methods inherited from Base
backup_support!, confirmable!, inherited, require_game_stopped!
Instance Attribute Details
#logger ⇒ Dry::Logger::Dispatcher (readonly)
Returns the value of attribute logger.
11 12 13 |
# File 'sig/factorix/cli/commands/mod/download.rbs', line 11 def logger @logger end |
#portal ⇒ Portal (readonly)
Returns the value of attribute portal.
10 11 12 |
# File 'sig/factorix/cli/commands/mod/download.rbs', line 10 def portal @portal end |
Instance Method Details
#call(mod_specs:, directory: ".", jobs: "4", recursive: false) ⇒ void
This method returns an undefined value.
Execute the download command
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/factorix/cli/commands/mod/download.rb', line 42 def call(mod_specs:, directory: ".", jobs: "4", recursive: false, **) jobs = Integer(jobs) download_dir = Pathname(directory). raise DirectoryNotFoundError, "Download directory does not exist: #{download_dir}" unless download_dir.exist? if runtime.mod_dir.exist? && download_dir.realpath == runtime.mod_dir.realpath raise InvalidOperationError, "Cannot download to MOD directory. Use 'mod install' instead." end download_targets = plan_download(mod_specs, download_dir, jobs, recursive) if download_targets.empty? say "No MOD(s) to download", prefix: :info return end download_mods(download_targets, jobs) say "Downloaded #{download_targets.size} MOD(s)", prefix: :success end |