Class: Factorix::CLI::Commands::MOD::List

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

Overview

List installed MODs

Defined Under Namespace

Classes: MODInfo

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Returns:



10
11
12
# File 'sig/factorix/cli/commands/mod/list.rbs', line 10

def logger
  @logger
end

#mod_portal_api ⇒ API::MODPortalAPI (readonly)

Returns the value of attribute mod_portal_api.

Returns:



12
13
14
# File 'sig/factorix/cli/commands/mod/list.rbs', line 12

def mod_portal_api
  @mod_portal_api
end

#runtime ⇒ Runtime (readonly)

Returns the value of attribute runtime.

Returns:



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

def runtime
  @runtime
end

Instance Method Details

#call(enabled:, disabled:, errors:, outdated:, json:) ⇒ void

This method returns an undefined value.

Execute the list command

Parameters:

  • show only enabled MODs

  • show only disabled MODs

  • show only MODs with dependency errors

  • show only MODs with available updates

  • output in JSON format



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/factorix/cli/commands/mod/list.rb', line 79

def call(enabled:, disabled:, errors:, outdated:, json:, **)
  validate_filter_options!(enabled:, disabled:, errors:, outdated:)

  mod_list = MODList.load
  presenter = Progress::Presenter.new(title: "\u{1F50D}\u{FE0E} Scanning MOD(s)", output: err)
  handler = Progress::ScanHandler.new(presenter)
  installed_mods = InstalledMOD.all(handler:)
  graph = Dependency::Graph::Builder.build(installed_mods:, mod_list:)

  validator = Dependency::Validator.new(graph:, mod_list:, installed_mods:)
  validation_result = validator.validate

  mod_infos = build_mod_infos(installed_mods, mod_list, validation_result)
  total_count = mod_infos.size

  # Apply filters
  mod_infos = apply_filters(mod_infos, enabled:, disabled:, errors:, outdated:)

  # Sort
  mod_infos = sort_mods(mod_infos)

  # Determine active filter for summary
  active_filter = if enabled then :enabled
                  elsif disabled then :disabled
                  elsif errors then :errors
                  elsif outdated then :outdated
                  end

  # Output
  if json
    output_json(mod_infos)
  else
    output_table(mod_infos, show_latest: outdated, active_filter:, total_count:)
  end
end