64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
BetterCurseForge Patcher — CLI
|
||
|
|
===============================
|
||
|
|
Command-line interface for patching CurseForge Launcher.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import sys, os
|
||
|
|
if os.name == "nt":
|
||
|
|
if sys.stdout is not None:
|
||
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||
|
|
if sys.stderr is not None:
|
||
|
|
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
|
||
|
|
|
||
|
|
try:
|
||
|
|
from . import patch_core
|
||
|
|
except ImportError:
|
||
|
|
import patch_core
|
||
|
|
|
||
|
|
VERSION = "1.0.0"
|
||
|
|
|
||
|
|
BANNER = r"""
|
||
|
|
╔══════════════════════════════════════════╗
|
||
|
|
║ ⬡ BetterCurseForge Patcher ⬡ ║
|
||
|
|
║ v{ver} ║
|
||
|
|
╚══════════════════════════════════════════╝
|
||
|
|
""".format(ver=VERSION)
|
||
|
|
|
||
|
|
def main():
|
||
|
|
print(BANNER)
|
||
|
|
if len(sys.argv) < 2:
|
||
|
|
print("Usage: python patcher.py [patch | unpatch | status | watch]")
|
||
|
|
print("For GUI, run without arguments or run patcher_gui.py")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
cmd = sys.argv[1].lower()
|
||
|
|
if cmd in ("watch", "--watch"):
|
||
|
|
patch_core.run_watcher_loop()
|
||
|
|
elif cmd == "--wait-for-update":
|
||
|
|
pid = int(sys.argv[2]) if len(sys.argv) > 2 and sys.argv[2].isdigit() else None
|
||
|
|
patch_core.wait_for_update_and_repatch(pid)
|
||
|
|
elif cmd == "--ensure-watcher":
|
||
|
|
if not patch_core.is_watcher_running():
|
||
|
|
patch_core.start_background_watcher()
|
||
|
|
elif cmd == "patch":
|
||
|
|
patch_core.patch_curseforge()
|
||
|
|
elif cmd == "unpatch":
|
||
|
|
patch_core.unpatch_curseforge()
|
||
|
|
elif cmd == "status":
|
||
|
|
cf = patch_core.get_curseforge_dir()
|
||
|
|
if not cf:
|
||
|
|
print("CurseForge installation not found.")
|
||
|
|
else:
|
||
|
|
print(f"CurseForge directory: {cf}")
|
||
|
|
patched = patch_core.is_curseforge_patched(cf)
|
||
|
|
print(f"Patch status: {'PATCHED' if patched else 'NOT PATCHED'}")
|
||
|
|
print(f"Auto-repatch watcher: {'ACTIVE' if patch_core.is_watcher_running() else 'INACTIVE'}")
|
||
|
|
else:
|
||
|
|
print(f"Unknown command: {cmd}")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|