2021-03-08 01:56:00 +00:00
|
|
|
import sys
|
2021-03-12 00:39:39 +00:00
|
|
|
|
|
|
|
from utils.consoleoutput import oColors
|
2021-03-21 13:30:27 +00:00
|
|
|
from utils.utilities import getHelp, getCommandHelp
|
2021-03-27 11:07:19 +00:00
|
|
|
from handlers.handle_config import configurationValues
|
2021-03-12 00:39:39 +00:00
|
|
|
from plugin.plugin_downloader import searchPackage, getSpecificPackage
|
|
|
|
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
|
|
|
from plugin.plugin_remover import removePlugin
|
2021-03-15 15:26:00 +00:00
|
|
|
from serverjar.serverjar_checker import checkInstalledServerjar, updateServerjar
|
2021-03-16 20:10:09 +00:00
|
|
|
from serverjar.serverjar_paper import papermc_downloader
|
2021-03-15 15:26:00 +00:00
|
|
|
|
2021-03-08 01:56:00 +00:00
|
|
|
|
|
|
|
def createInputLists():
|
|
|
|
global COMMANDLIST
|
|
|
|
COMMANDLIST = [
|
|
|
|
'get',
|
|
|
|
'update',
|
|
|
|
'check',
|
2021-03-13 21:09:32 +00:00
|
|
|
'search',
|
2021-03-08 21:13:57 +00:00
|
|
|
'exit',
|
2021-03-10 22:49:57 +00:00
|
|
|
'help',
|
2021-03-15 15:26:00 +00:00
|
|
|
'remove',
|
|
|
|
'get-paper'
|
2021-03-08 01:56:00 +00:00
|
|
|
]
|
|
|
|
global INPUTSELECTEDOBJECT
|
|
|
|
INPUTSELECTEDOBJECT = [
|
|
|
|
'all',
|
|
|
|
'*'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def handleInput(inputCommand, inputSelectedObject, inputParams):
|
2021-03-27 11:07:19 +00:00
|
|
|
configValues = configurationValues()
|
2021-03-08 01:56:00 +00:00
|
|
|
while True:
|
|
|
|
if inputCommand == 'get':
|
2021-03-08 21:13:57 +00:00
|
|
|
if inputSelectedObject.isdigit():
|
2021-03-27 11:07:19 +00:00
|
|
|
if not configValues.localPluginFolder:
|
|
|
|
if configValues.sftp_seperateDownloadPath is True:
|
|
|
|
pluginPath = configValues.sftp_pathToSeperateDownloadPath
|
2021-03-14 12:25:13 +00:00
|
|
|
else:
|
2021-03-27 11:07:19 +00:00
|
|
|
pluginPath = configValues.sftp_folderPath
|
2021-03-14 12:25:13 +00:00
|
|
|
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
2021-03-10 01:05:56 +00:00
|
|
|
break
|
|
|
|
else:
|
2021-03-27 11:07:19 +00:00
|
|
|
if configValues.seperateDownloadPath is True:
|
|
|
|
pluginPath = configValues.pathToSeperateDownloadPath
|
2021-03-14 12:25:13 +00:00
|
|
|
else:
|
2021-03-27 11:07:19 +00:00
|
|
|
pluginPath = configValues.pathToPluginFolder
|
2021-03-14 12:25:13 +00:00
|
|
|
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
2021-03-12 00:39:39 +00:00
|
|
|
break
|
2021-03-08 21:13:57 +00:00
|
|
|
else:
|
|
|
|
searchPackage(inputSelectedObject)
|
|
|
|
break
|
2021-03-08 01:56:00 +00:00
|
|
|
if inputCommand == 'update':
|
2021-03-15 15:26:00 +00:00
|
|
|
if inputSelectedObject == 'serverjar':
|
|
|
|
updateServerjar(inputParams)
|
|
|
|
else:
|
|
|
|
updateInstalledPackage(inputSelectedObject)
|
2021-03-08 01:56:00 +00:00
|
|
|
break
|
|
|
|
if inputCommand == 'check':
|
2021-03-15 15:26:00 +00:00
|
|
|
if inputSelectedObject == 'serverjar':
|
|
|
|
checkInstalledServerjar()
|
|
|
|
else:
|
|
|
|
checkInstalledPackage(inputSelectedObject)
|
2021-03-08 01:56:00 +00:00
|
|
|
break
|
2021-03-13 21:09:32 +00:00
|
|
|
if inputCommand == 'search':
|
|
|
|
searchPackage(inputSelectedObject)
|
|
|
|
break
|
2021-03-08 01:56:00 +00:00
|
|
|
if inputCommand == 'exit':
|
|
|
|
sys.exit()
|
2021-03-08 21:13:57 +00:00
|
|
|
if inputCommand == 'help':
|
2021-03-21 13:30:27 +00:00
|
|
|
if inputSelectedObject == 'command' or inputSelectedObject == 'commands':
|
|
|
|
getCommandHelp(inputParams)
|
|
|
|
else:
|
|
|
|
getHelp()
|
2021-03-08 21:13:57 +00:00
|
|
|
break
|
2021-03-10 22:49:57 +00:00
|
|
|
if inputCommand == 'remove':
|
|
|
|
removePlugin(inputSelectedObject)
|
2021-03-10 01:05:56 +00:00
|
|
|
break
|
2021-03-15 15:26:00 +00:00
|
|
|
if inputCommand == 'get-paper':
|
|
|
|
papermc_downloader(inputSelectedObject, inputParams)
|
|
|
|
break
|
2021-03-08 01:56:00 +00:00
|
|
|
else:
|
2021-03-21 13:30:27 +00:00
|
|
|
print(oColors.brightRed + "Error: Command not found. Please try again. :(" + oColors.standardWhite)
|
2021-03-30 21:55:04 +00:00
|
|
|
print(oColors.brightRed + "Use: '" + oColors.standardWhite +"help command" + oColors.brightRed +"' to get all available commands" + oColors.standardWhite)
|
2021-03-08 01:56:00 +00:00
|
|
|
getInput()
|
|
|
|
getInput()
|
2021-03-07 00:49:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def getInput():
|
2021-03-30 21:55:04 +00:00
|
|
|
inputCommand = None
|
2021-03-08 01:56:00 +00:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
inputCommand, inputSelectedObject, *inputParams = input("pluGET >> ").split()
|
|
|
|
break
|
|
|
|
except ValueError:
|
2021-03-30 21:55:04 +00:00
|
|
|
if inputCommand == None:
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
print(oColors.brightRed + "Wrong input! Use: > 'command' 'selectedObject' [optionalParams]" + oColors.standardWhite)
|
|
|
|
print(oColors.brightRed + "Use: '" + oColors.standardWhite +"help command" + oColors.brightRed +"' to get all available commands" + oColors.standardWhite)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
sys.exit()
|
2021-03-08 01:56:00 +00:00
|
|
|
inputParams = inputParams[0] if inputParams else None
|
|
|
|
handleInput(inputCommand, inputSelectedObject, inputParams)
|