Class: Factorix::CLI::Commands::MOD::Disable
- Defined in:
- lib/factorix/cli/commands/mod/disable.rb
Overview
Disable MODs in mod-list.json with reverse dependency resolution
Instance Method Summary collapse
-
#call(mod_names: [], all: false) ⇒ void
Execute the disable command.
Methods inherited from Base
backup_support!, confirmable!, inherited, require_game_stopped!
Instance Method Details
#call(mod_names: [], all: false) ⇒ void
This method returns an undefined value.
Execute the disable command
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/factorix/cli/commands/mod/disable.rb', line 37 def call(mod_names: [], all: false, **) validate_arguments(mod_names, all) # Without validation to allow fixing issues 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:) target_mods = if all plan_disable_all(graph) else mod_names.map {|name| Factorix::MOD[name:] } end validate_target_mods(target_mods, graph) mods_to_disable = plan_with_dependents(target_mods, graph) show_plan(mods_to_disable) return if mods_to_disable.empty? return unless confirm?("Do you want to disable these MOD(s)?") execute_plan(mods_to_disable, mod_list) backup_if_exists(runtime.mod_list_path) mod_list.save say "Disabled #{mods_to_disable.size} MOD(s)", prefix: :success say "Saved mod-list.json", prefix: :success logger.debug("Saved mod-list.json") end |