2024-04-20 04:26:43 +05:30
|
|
|
import json
|
2025-01-15 04:15:39 +05:30
|
|
|
import sys
|
2024-04-20 04:26:43 +05:30
|
|
|
|
2025-01-14 22:46:36 +00:00
|
|
|
|
2026-01-05 03:00:15 +05:30
|
|
|
def get_latest_plugman_version() -> str:
|
2024-04-20 09:06:50 +05:30
|
|
|
"""Get latest version entry from index.json"""
|
2024-04-20 04:26:43 +05:30
|
|
|
with open('index.json', 'r') as file:
|
|
|
|
|
content = json.loads(file.read())
|
|
|
|
|
latest_version = list(content["versions"].keys())[0]
|
|
|
|
|
return latest_version
|
|
|
|
|
|
2025-01-14 22:46:36 +00:00
|
|
|
|
2026-01-05 03:00:15 +05:30
|
|
|
def get_latest_plugin_version(plugin_name, json_path) -> str:
|
|
|
|
|
"""Get latest version entry from json file for a specific plugin"""
|
|
|
|
|
with open(json_path, 'r') as file:
|
|
|
|
|
content = json.loads(file.read())
|
|
|
|
|
latest_version = list(content["plugins"][plugin_name]["versions"].keys())[0]
|
|
|
|
|
return latest_version
|
|
|
|
|
|
|
|
|
|
|
2025-01-15 04:15:39 +05:30
|
|
|
def get_latest_api():
|
|
|
|
|
"""Get latest api entry from index.json"""
|
|
|
|
|
with open('index.json', 'r') as file:
|
|
|
|
|
content = json.loads(file.read())
|
2026-01-05 03:00:15 +05:30
|
|
|
latest_api = content["versions"][get_latest_plugman_version()]["api_version"]
|
2025-01-15 04:15:39 +05:30
|
|
|
return latest_api
|
2024-04-20 04:26:43 +05:30
|
|
|
|
2025-01-14 22:46:36 +00:00
|
|
|
|
2024-04-20 04:26:43 +05:30
|
|
|
if __name__ == "__main__":
|
2025-01-15 04:15:39 +05:30
|
|
|
if len(sys.argv) < 2:
|
2026-01-05 03:00:15 +05:30
|
|
|
print(f"Usage: python3 {__file__.split('/')[-1]} function [args...]")
|
2025-01-15 04:15:39 +05:30
|
|
|
sys.exit(1)
|
2026-01-05 03:00:15 +05:30
|
|
|
function_name = sys.argv[1]
|
|
|
|
|
function_args = sys.argv[2:]
|
|
|
|
|
print(
|
|
|
|
|
globals()[function_name](*function_args)
|
|
|
|
|
) # used to call the function passed as cli parameter with additional arguments
|