Class: Nauvisian::CLI::Commands::Save::Mod::Sync
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Nauvisian::CLI::Commands::Save::Mod::Sync
- Includes:
- DownloadHelper, MessageHelper
- Defined in:
- lib/nauvisian/cli/commands/save/mod/sync.rb
Defined Under Namespace
Classes: ExistingMods
Instance Method Summary collapse
Instance Method Details
#call(save_file:, **options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nauvisian/cli/commands/save/mod/sync.rb', line 22 def call(save_file:, **) save_file_path = Pathname(save_file) save = Nauvisian::Save.load(save_file_path) mods_in_save = save.mods.sort # [[mod, version]] [:mod_directory] = Pathname([:mod_directory]) existing_mods = ExistingMods.new(**) downloader = Nauvisian::Downloader.new(credential: find_credential, progress: [:verbose] ? Nauvisian::Progress::Bar : Nauvisian::Progress::Null) mods_in_save.each do |mod, version| next if mod.base? release = existing_mods.release_to_download(mod, version) next unless release downloader.download(release, [:mod_directory] / release.file_name) end list = Nauvisian::ModList.new(mods_in_save.map {|mod, _version| [mod, true] }) list.save([:mod_directory] / "mod-list.json") settings = Nauvisian::ModSettings.load([:mod_directory] / "mod-settings.dat") settings["startup"] = save.startup_settings settings.save([:mod_directory] / "mod-settings.dat") rescue => e (e) exit 1 end |