fabulously-optimized/CLI tools/Update version.py

32 lines
1.1 KiB
Python
Raw Permalink Normal View History

import json
from pathlib import Path
2022-08-22 10:49:10 +00:00
mmc_path = Path.home() / "curseforge/minecraft/Instances/Fabulously Optimized/"
title_screen_path = mmc_path / "config/isxander-main-menu-credits.json"
warning_path = mmc_path / "config/fabric_loader_dependencies.json"
2022-08-22 10:49:10 +00:00
def load_json(path: Path) -> dict:
with open(path, "r") as f:
return json.load(f)
def save_file(path: Path, obj) -> None:
2022-08-22 11:15:14 +00:00
with open(path, "w") as f:
json.dump(obj, f, separators=(",", ":"))
2022-08-22 10:49:10 +00:00
2022-08-22 11:15:14 +00:00
title_screen_obj = load_json(title_screen_path)
existing_version = title_screen_obj["main_menu"]["bottom_right"][0]["text"]
2022-08-22 10:49:10 +00:00
print(f"Current version: {existing_version}")
2022-08-22 11:15:14 +00:00
new_version = input("Enter new version: Fabulously Optimized ")
2022-08-22 10:49:10 +00:00
title_screen_obj["main_menu"]["bottom_right"][0]["text"] = f"Fabulously Optimized {new_version}"
2022-08-22 11:15:14 +00:00
save_file(title_screen_path, title_screen_obj)
2022-08-22 10:49:10 +00:00
2022-08-22 11:15:14 +00:00
warning_file_obj = load_json(warning_path)
warning_file_obj["overrides"]["minecraft"]["+recommends"]["Fabulously Optimized"] = f">{new_version}"
save_file(warning_path, warning_file_obj)