2020-07-02 22:46:42 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2020-10-17 00:26:41 +03:00
|
|
|
import sys
|
2020-07-02 22:46:42 +03:00
|
|
|
import json
|
2020-10-05 03:14:05 +03:00
|
|
|
import click
|
2020-07-02 22:46:42 +03:00
|
|
|
|
2020-10-05 03:19:23 +03:00
|
|
|
__author__ = "Alexander Popov"
|
2020-11-22 03:35:27 +03:00
|
|
|
__version__ = "1.0.2"
|
2020-10-05 03:19:23 +03:00
|
|
|
__license__ = "Unlicense"
|
2020-07-02 22:46:42 +03:00
|
|
|
|
|
|
|
|
2020-10-05 03:14:05 +03:00
|
|
|
@click.command()
|
2020-10-17 00:26:41 +03:00
|
|
|
@click.option("--platform", default=sys.platform, help="Output platform (win32, linux, darwin).")
|
2020-10-10 03:04:51 +03:00
|
|
|
@click.option("--output", default="tty", help="Output option (tty, txt).")
|
|
|
|
def make_output(platform, output):
|
2020-10-05 03:14:05 +03:00
|
|
|
""" Return libraries list """
|
|
|
|
|
|
|
|
libraries = parse_libs()
|
|
|
|
|
2020-10-10 03:04:51 +03:00
|
|
|
# OS libs separate
|
2020-11-22 03:35:27 +03:00
|
|
|
_ = {"win32": ";", "linux": ":", "darwin": ":"}
|
2020-10-05 03:14:05 +03:00
|
|
|
|
2020-10-10 03:04:51 +03:00
|
|
|
out_lib = str()
|
2020-10-05 03:14:05 +03:00
|
|
|
|
2020-10-10 03:04:51 +03:00
|
|
|
# Generate libraries list
|
2020-10-05 03:14:05 +03:00
|
|
|
for lib in libraries:
|
2020-10-10 03:04:51 +03:00
|
|
|
out_lib = out_lib + "$MC_DIR/libraries/{0}".format(lib) + _[platform]
|
2020-10-05 03:14:05 +03:00
|
|
|
|
2020-10-10 03:04:51 +03:00
|
|
|
out_lib = out_lib + "$MC_DIR/versions/$GAME_VERSION/$GAME_VERSION.jar"
|
2020-10-05 03:14:05 +03:00
|
|
|
|
2020-10-10 03:04:51 +03:00
|
|
|
# Replace for OS shell variable symbol
|
2020-10-17 00:26:41 +03:00
|
|
|
if platform == "win32":
|
2020-10-10 03:04:51 +03:00
|
|
|
out_lib = out_lib.replace("$MC_DIR", "%MC_DIR%")
|
|
|
|
out_lib = out_lib.replace("$GAME_VERSION", "%GAME_VERSION%")
|
|
|
|
|
|
|
|
if output == "tty":
|
|
|
|
click.echo(out_lib)
|
|
|
|
|
2020-10-17 00:26:41 +03:00
|
|
|
if platform == "win32":
|
2020-10-10 03:04:51 +03:00
|
|
|
print("\nWindows generate libraries list complete!")
|
2020-10-17 00:26:41 +03:00
|
|
|
elif platform == "linux" or platform == "darwin":
|
2020-11-22 03:38:06 +03:00
|
|
|
print("\nUnix generate libraries list complete!")
|
2020-10-10 03:04:51 +03:00
|
|
|
elif output == "txt":
|
|
|
|
with open("./libs.txt", "w", encoding="utf-8") as f:
|
|
|
|
f.write(out_lib)
|
|
|
|
|
2020-10-17 00:26:41 +03:00
|
|
|
if platform == "win32":
|
2020-10-10 03:04:51 +03:00
|
|
|
print("\nWindows generate libraries list complete!\n" "See libs.txt file.")
|
2020-10-17 00:26:41 +03:00
|
|
|
elif platform == "linux" or platform == "darwin":
|
2020-11-22 03:38:06 +03:00
|
|
|
print("\nUnix generate libraries list complete!\n" "See libs.txt file.")
|
2020-10-10 02:29:27 +03:00
|
|
|
|
2020-10-05 03:14:05 +03:00
|
|
|
|
2020-07-02 22:46:42 +03:00
|
|
|
def parse_libs():
|
2020-07-02 22:52:36 +03:00
|
|
|
""" Make libraries list from version.json file """
|
|
|
|
|
2020-07-02 22:46:42 +03:00
|
|
|
_ = []
|
|
|
|
|
2020-10-05 03:19:23 +03:00
|
|
|
with open("./version.json", "r", encoding="utf-8") as f:
|
2020-07-02 22:46:42 +03:00
|
|
|
file_data = json.loads(f.read())
|
|
|
|
|
2020-10-05 03:19:23 +03:00
|
|
|
for lib in file_data["libraries"]:
|
|
|
|
_.append(lib["downloads"]["artifact"]["path"])
|
2020-07-02 22:46:42 +03:00
|
|
|
|
2020-10-05 03:19:23 +03:00
|
|
|
return _
|
2020-07-02 22:46:42 +03:00
|
|
|
|
|
|
|
|
2020-10-05 03:19:23 +03:00
|
|
|
if __name__ == "__main__":
|
2020-10-05 03:14:05 +03:00
|
|
|
make_output()
|