Class: Factorix::CLI::Commands::MOD::Image::Add

Inherits:
Base show all
Includes:
PortalSupport
Defined in:
lib/factorix/cli/commands/mod/image/add.rb,
sig/factorix/cli/commands/mod/image/add.rbs

Overview

Add an image to a MOD on Factorio MOD Portal

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

backup_support!, confirmable!, inherited, require_game_stopped!

Instance Attribute Details

#portal ⇒ Portal (readonly)

Returns the value of attribute portal.

Returns:



11
12
13
# File 'sig/factorix/cli/commands/mod/image/add.rbs', line 11

def portal
  @portal
end

Instance Method Details

#call(mod_name:, image_file:) ⇒ void

This method returns an undefined value.

Execute the add command

Parameters:

  • mod_name (String) —

    the MOD name

  • image_file (String) —

    path to image file

  • mod_name: (String)
  • image_file: (String)
  • (Object)

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/factorix/cli/commands/mod/image/add.rb', line 26

def call(mod_name:, image_file:, **)
  file_path = Pathname(image_file)

  raise InvalidArgumentError, "Image file not found: #{image_file}" unless file_path.exist?

  # Add image via Portal
  image = portal.add_mod_image(mod_name, file_path)

  say "Image added successfully!", prefix: :success
  say "  ID: #{image.id}"
  say "  Thumbnail: #{image.thumbnail}"
  say "  Full URL: #{image.url}"
end