Class: Factorix::CLI::Commands::Launch

Inherits:
Base show all
Defined in:
lib/factorix/cli/commands/launch.rb,
sig/factorix/cli/commands/launch.rbs

Overview

Launch Factorio game

This command launches the Factorio game executable with optional arguments. By default, the game is launched asynchronously (in the background), but certain options like --help and --dump-* are automatically detected and run synchronously.

Instance Method Summary collapse

Methods inherited from Base

backup_support!, confirmable!, inherited, require_game_stopped!

Instance Method Details

#call(wait: false, args: []) ⇒ void

This method returns an undefined value.

Execute the launch command

Parameters:

  • wait (Boolean) (defaults to: false) —

    whether to wait for the game to finish

  • args (Array<String>) (defaults to: []) —

    additional arguments to pass to Factorio

  • wait: (Boolean) (defaults to: false)
  • args: (Array[String]) (defaults to: [])


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/factorix/cli/commands/launch.rb', line 48

def call(wait: false, args: [], **)
  logger.info("Launching Factorio", args:)

  async = args.none? {|arg| SYNCHRONOUS_OPTIONS.include?(arg) }

  runtime.launch(*args, async:)
  logger.info("Factorio launched successfully", async:)

  return unless async && wait

  logger.debug("Waiting for game to start")
  wait_while { !runtime.running? }
  logger.debug("Game started, waiting for termination")
  wait_while { runtime.running? }
  logger.info("Game terminated")
end