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

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

Overview

List installed MODs

Defined Under Namespace

Classes: MODInfo

Instance Method Summary collapse

Methods inherited from Base

backup_support!, confirmable!, inherited, require_game_stopped!

Instance Method Details

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

This method returns an undefined value.

Execute the list command

Parameters:

  • enabled (Boolean)

    show only enabled MODs

  • disabled (Boolean)

    show only disabled MODs

  • errors (Boolean)

    show only MODs with dependency errors

  • outdated (Boolean)

    show only MODs with available updates

  • json (Boolean)

    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