mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
Added plugin downloader capabilities
Added plugin downloader capabilities and added full console argument support. Fixed #46 and added error handling for it
This commit is contained in:
@@ -19,7 +19,7 @@ class config_value():
|
||||
yaml = ruamel.yaml.YAML()
|
||||
with open("pluGET_config.yaml", "r") as config_file:
|
||||
data = yaml.load(config_file)
|
||||
self.connection = data["Connection"]
|
||||
self.connection = str(data["Connection"]).lower()
|
||||
self.path_to_plugin_folder = Path(data["Local"]["PathToPluginFolder"])
|
||||
self.local_seperate_download_path = True if data["Local"]["SeperateDownloadPath"] == True else False
|
||||
self.local_path_to_seperate_download_path = Path(data["Local"]["PathToSeperateDownloadPath"])
|
||||
@@ -100,7 +100,7 @@ def validate_config() -> None:
|
||||
config = config_value()
|
||||
# rich console for nice colors
|
||||
console = Console()
|
||||
if (config.connection).lower() not in accepted_values[0]:
|
||||
if config.connection not in accepted_values[0]:
|
||||
console.print(f"Error in Config! Accepted values for key 'Connection' are {accepted_values[0]}",
|
||||
style="bright_red")
|
||||
exit_afterwards = True
|
||||
|
@@ -1,8 +1,9 @@
|
||||
""""
|
||||
Handles the input through the pluGET command line
|
||||
Handles the input through the pluGET command line
|
||||
"""
|
||||
|
||||
from src.utils.utilities import rich_print_error
|
||||
from src.plugin.plugin_downloader import get_specific_plugin
|
||||
|
||||
|
||||
# check
|
||||
@@ -16,23 +17,24 @@ from src.utils.utilities import rich_print_error
|
||||
# search ???
|
||||
|
||||
|
||||
def handle_input() -> None:
|
||||
def handle_input(input_command=None, input_selected_object=None, input_parameter=None, arguments_from_console=False) -> None:
|
||||
"""
|
||||
Manages the correct function calling from the given input
|
||||
Manages the correct function calling from the given input
|
||||
"""
|
||||
while True:
|
||||
try:
|
||||
input_command, input_selected_object, input_parameter = get_input()
|
||||
except TypeError:
|
||||
# KeyboardInterrupt was triggered and None was returned so exit
|
||||
return
|
||||
# when arguemnts were not passed from console
|
||||
if arguments_from_console is False:
|
||||
try:
|
||||
input_command, input_selected_object, input_parameter = get_input()
|
||||
except TypeError:
|
||||
# KeyboardInterrupt was triggered and None was returned so exit
|
||||
return
|
||||
|
||||
match input_command:
|
||||
case "get":
|
||||
match input_selected_object.isdigit():
|
||||
case True:
|
||||
print("get specific package")
|
||||
#getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
||||
get_specific_plugin(input_selected_object, input_parameter)
|
||||
case _:
|
||||
print("get search specific package")
|
||||
#searchPackage(inputSelectedObject)
|
||||
@@ -67,16 +69,23 @@ def handle_input() -> None:
|
||||
# download papermc
|
||||
print("download papermc")
|
||||
#papermc_downloader(inputSelectedObject, inputParams)
|
||||
case "exit":
|
||||
return
|
||||
case _:
|
||||
rich_print_error("Error: Command not found. Please try again. :(")
|
||||
rich_print_error("Use: 'help command' to get all available commands")
|
||||
|
||||
# return to break out of while loop
|
||||
if arguments_from_console:
|
||||
return None
|
||||
|
||||
|
||||
def get_input() -> None:
|
||||
"""
|
||||
Gets command line input and calls the handle input function
|
||||
"""
|
||||
input_command = None
|
||||
print("'STRG + C' to exit")
|
||||
while True:
|
||||
try:
|
||||
input_command, input_selected_object, *input_parameter = input("pluGET >> ").split()
|
||||
|
Reference in New Issue
Block a user