pluGET/pluget.py

46 lines
1.9 KiB
Python
Raw Normal View History

"""
Handles the main function and the argument passing for the whole pluGET program
"""
import sys
import argparse
# check if folder 'src' is accessible with all modules needed and if not exit
try:
2022-06-16 19:26:43 +00:00
from src.handlers.handle_config import check_config, validate_config
2022-06-20 15:21:58 +00:00
from src.utils.console_output import rename_console_title, clear_console, print_logo, print_console_logo
from src.utils.utilities import check_requirements, api_test_spiget, check_for_pluGET_update
2022-06-16 19:26:43 +00:00
from src.handlers.handle_input import handle_input
2022-06-20 15:21:58 +00:00
except TypeError:
2022-06-16 20:35:54 +00:00
print("Folder 'src' not found in the directory or missing files or broken functions detected! \
2022-06-16 19:26:43 +00:00
\nPlease redownload the files from here: https://www.github.com/Neocky/pluGET")
sys.exit()
if __name__ == "__main__":
2022-06-16 19:26:43 +00:00
parser = argparse.ArgumentParser(description="Arguments for pluGET",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
2022-06-16 20:35:54 +00:00
parser.add_argument("mode", help="Mode (install/update/etc.)", nargs='?', default=None)
2022-06-16 19:26:43 +00:00
parser.add_argument("object", help="Object/Plugin Name", nargs='?', default=None)
parser.add_argument("version", help="Version", nargs='?', default=None)
2022-06-22 10:58:48 +00:00
parser.add_argument("--no-confirmation", action="store_true", help="Skip confirmation messages")
2022-06-16 19:26:43 +00:00
args = vars(parser.parse_args())
2022-06-20 15:21:58 +00:00
rename_console_title()
check_config()
validate_config()
api_test_spiget()
check_requirements()
2022-06-16 19:26:43 +00:00
if args["mode"] is not None and args["object"] is not None:
# arguments were used so call the handle_input function to get the right function call
2022-06-20 15:21:58 +00:00
print_console_logo()
check_for_pluGET_update()
2022-06-22 10:58:48 +00:00
handle_input(args["mode"], args["object"], args["version"], args["no_confirmation"], arguments_from_console=True)
2022-06-16 19:26:43 +00:00
else:
# no arguments were used so start pluGET console
clear_console()
2022-06-16 19:26:43 +00:00
print_logo()
2022-06-20 15:21:58 +00:00
check_for_pluGET_update()
2022-06-16 19:26:43 +00:00
handle_input()