diff --git a/vollerei/cli/__init__.py b/vollerei/cli/__init__.py
index b36bcd3..bce6a16 100644
--- a/vollerei/cli/__init__.py
+++ b/vollerei/cli/__init__.py
@@ -3,7 +3,7 @@ from vollerei.cli import hsr
application = Application()
for command in hsr.commands:
- application.add(command)
+ application.add(command())
def run():
diff --git a/vollerei/cli/hsr.py b/vollerei/cli/hsr.py
index 94f41a2..270ec55 100644
--- a/vollerei/cli/hsr.py
+++ b/vollerei/cli/hsr.py
@@ -1,21 +1,19 @@
from cleo.commands.command import Command
-from cleo.helpers import option
+from cleo.helpers import option, argument
from platform import system
from vollerei.hsr.launcher.enums import GameChannel
-from vollerei.paths import set_base_path, base_paths
from vollerei.cli import utils
from vollerei.exceptions.game import GameError
from vollerei.hsr import Game, Patcher
from vollerei.exceptions.patcher import PatcherError, PatchUpdateError
from vollerei.hsr.patcher import PatchType
-from tqdm import tqdm
-import requests
patcher = Patcher()
default_options = [
option("channel", "c", description="Game channel", flag=False, default="overseas"),
+ option("force", "f", description="Force the command to run"),
option(
"game-path",
"g",
@@ -289,12 +287,60 @@ class UpdateCommand(Command):
)
return
progress.finish("Update applied.")
+ self.line("Setting version config... ")
+ self.set_version_config()
+ self.line(
+ f"The game has been updated to version: {State.game.get_version_str()}"
+ )
+
+
+class ApplyUpdateArchive(Command):
+ name = "hsr update apply-archive"
+ description = "Applies the update archive to the local game"
+ arguments = [argument("path", description="Path to the update archive")]
+ options = default_options + [
+ option(
+ "auto-repair", "R", description="Automatically repair the game if needed"
+ ),
+ ]
+
+ def handle(self):
+ callback(command=self)
+ auto_repair = self.option("auto-repair")
+ update_archive = self.argument("path")
+ if auto_repair:
+ self.line("Auto-repair is enabled.")
+ progress = utils.ProgressIndicator(self)
+ progress.start("Applying update package...")
+ try:
+ State.game.apply_update_archive(update_archive, auto_repair=auto_repair)
+ except Exception as e:
+ progress.finish(
+ f"Couldn't apply update: {e} ({e.__context__})"
+ )
+ return
+ progress.finish("Update applied.")
+ self.line("Setting version config... ")
+ try:
+ State.game.set_version_config()
+ except Exception as e:
+ self.line_error(f"Couldn't set version config: {e}")
+ self.line_error(
+ "This won't affect the overall experience, but if you're using the official launcher"
+ )
+ self.line_error(
+ "you may have to edit the file 'config.ini' manually to reflect the latest version."
+ )
+ self.line(
+ f"The game has been updated to version: {State.game.get_version_str()}"
+ )
commands = [
- UpdateCommand(),
- PatchTypeCommand(),
- UpdatePatchCommand(),
- PatchInstallCommand(),
- GetVersionCommand(),
+ ApplyUpdateArchive,
+ UpdateCommand,
+ PatchTypeCommand,
+ UpdatePatchCommand,
+ PatchInstallCommand,
+ GetVersionCommand,
]
diff --git a/vollerei/hsr/launcher/game.py b/vollerei/hsr/launcher/game.py
index 9fcc7e9..f2f979d 100644
--- a/vollerei/hsr/launcher/game.py
+++ b/vollerei/hsr/launcher/game.py
@@ -347,7 +347,6 @@ class Game(GameABC):
archive_file = Path(archive_file)
# Hello hell again, dealing with HDiffPatch and all the things again.
functions.apply_update_archive(self, archive_file, auto_repair=auto_repair)
- self.set_version_config()
def install_update(
self, update_info: resource.Diff = None, auto_repair: bool = True
@@ -370,3 +369,4 @@ class Game(GameABC):
archive_file = self._cache.joinpath(update_info.name)
download(update_info.path, archive_file)
self.apply_update_archive(archive_file=archive_file, auto_repair=auto_repair)
+ self.set_version_config()