Class: Factorix::CLI::Commands::Download

Inherits:
Base
  • Object
show all
Defined in:
lib/factorix/cli/commands/download.rb

Overview

Download Factorio game files from the official download API

Instance Method Summary collapse

Methods inherited from Base

backup_support!, confirmable!, inherited, require_game_stopped!

Instance Method Details

#call(version: "latest", build: "alpha", platform: nil, channel: "stable", directory: ".", output: nil) ⇒ void

This method returns an undefined value.

Execute the download command

Parameters:

  • version (String) (defaults to: "latest")

    Version to download

  • build (String) (defaults to: "alpha")

    Build type

  • platform (String, nil) (defaults to: nil)

    Platform (nil for auto-detect)

  • channel (String) (defaults to: "stable")

    Release channel

  • directory (String) (defaults to: ".")

    Download directory

  • output (String, nil) (defaults to: nil)

    Output filename

Raises:



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/factorix/cli/commands/download.rb', line 54

def call(version: "latest", build: "alpha", platform: nil, channel: "stable", directory: ".", output: nil, **)
  platform ||= detect_platform
  resolved_version = resolve_version(version, channel, build)

  download_dir = Pathname(directory).expand_path
  raise DirectoryNotFoundError, "Download directory does not exist: #{download_dir}" unless download_dir.exist?

  filename = output || resolve_filename(resolved_version, build, platform)
  output_path = download_dir / filename

  say "Downloading Factorio #{resolved_version} (#{build}/#{platform})...", prefix: :info

  download_game(resolved_version, build, platform, output_path)

  say "Downloaded to #{output_path}", prefix: :success
end