Added new help command

- added new help command
- fixed some formating issues
This commit is contained in:
Jan-Luca Bogdan | BEL NET GmbH 2022-07-04 15:55:08 +02:00
parent 6b926c9564
commit 0e09daae53
2 changed files with 73 additions and 2 deletions

View File

@ -3,6 +3,7 @@ Handles the input through the pluGET command line
"""
from src.utils.console_output import rich_print_error
from src.utils.utilities import get_command_help
from src.plugin.plugin_remover import delete_plugin
from src.plugin.plugin_downloader import get_specific_plugin_spiget, search_specific_plugin_spiget
from src.plugin.plugin_updatechecker import check_installed_plugins, update_installed_plugins
@ -22,6 +23,7 @@ from src.serverjar.serverjar_purpur import serverjar_purpur_update
# exit
# remove
# search
# help
def handle_input(
@ -86,11 +88,13 @@ def handle_input(
search_specific_plugin_spiget(input_selected_object)
case "remove":
delete_plugin(input_selected_object)
case "help":
get_command_help(input_selected_object)
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")
rich_print_error("Use [bright_blue]'help all' [bright_red]to get a list of all available commands.")
# return to break out of while loop if pluGET was started with arguments from console
if arguments_from_console:
@ -117,7 +121,7 @@ def get_input() -> str:
continue
else:
rich_print_error("Wrong input! Use: > 'command' 'selectedObject' [optionalParams]")
rich_print_error("Use: 'help command' to get all available commands")
rich_print_error("Use: [bright_blue]'help all' [bright_red]to get a list of all available commands.")
except KeyboardInterrupt:
return
input_parameter = input_parameter[0] if input_parameter else None

View File

@ -9,6 +9,7 @@ import shutil
import re
from pathlib import Path
from rich.console import Console
from rich.table import Table
from src.handlers.handle_sftp import sftp_create_connection
from src.handlers.handle_ftp import ftp_create_connection
@ -17,6 +18,72 @@ from src.handlers.handle_config import config_value
from src.settings import PLUGETVERSION
def get_command_help(command: str) -> None:
"""
Prints the help page for all commands and individual commands
:param command: Console command which the help page should show
:returns: None
"""
rich_console = Console()
rich_table = Table(box=None)
rich_table.add_column("Command", justify="left", style="bright_blue", no_wrap=True)
rich_table.add_column("Object", style="bright_magenta")
rich_table.add_column("Params", justify="left", style="cyan")
rich_table.add_column("Description", justify="left", style="white")
match command:
case "all":
rich_table.add_row("check", "Name/all", None, "Check for an update of an installed plugin")
rich_table.add_row("check", "serverjar", None, "Check for an update for the installed serverjar")
rich_table.add_row("exit", "./anything", None, "Exit pluGET")
rich_table.add_row("get", "Name/ID", None, "Downloads the latest version of a plugin")
rich_table.add_row("get-paper", "PaperVersion", "McVersion", "Downloads a specific PaperMc version")
rich_table.add_row("get-purpur", "PurpurVersion", "McVersion", "Downloads a specific Purpur version")
rich_table.add_row("get-velocity", "VelocityVersion", "McVersion", "Downloads a specific Velocity version")
rich_table.add_row(
"get-waterfall", "WaterfallVersion", "McVersion", "Downloads a specific waterfall version"
)
rich_table.add_row("help", "./anything", None, "Get specific help to the commands of pluGET")
rich_table.add_row("remove", "Name", None, "Delete an installed plugin from the plugin folder")
rich_table.add_row("search", "Name/all", None, "Search for a plugin and download the latest version")
rich_table.add_row("update", "Name/all", None, "Update installed plugins to the latest version")
rich_table.add_row("update", "serverjar", None, "Update the installed serverjar to the latest version")
case "check":
rich_table.add_row("check", "Name/all", None, "Check for an update of an installed plugin")
rich_table.add_row("check", "serverjar", None, "Check for an update for the installed serverjar")
case "exit":
rich_table.add_row("exit", "./anything", None, "Exit pluGET")
case "get":
rich_table.add_row("get", "Name/ID", None, "Downloads the latest version of a plugin")
case "get-paper":
rich_table.add_row("get-paper", "PaperVersion", "McVersion", "Downloads a specific PaperMc version")
case "get-purpur":
rich_table.add_row("get-purpur", "PurpurVersion", "McVersion", "Downloads a specific Purpur version")
case "get-velocity":
rich_table.add_row("get-velocity", "VelocityVersion", "McVersion", "Downloads a specific Velocity version")
case "get-waterfall":
rich_table.add_row(
"get-waterfall", "WaterfallVersion", "McVersion", "Downloads a specific Waterfall version"
)
case "help" | "all":
rich_table.add_row("help", "./anything", None, "Get specific help to the commands of pluGET")
case "remove":
rich_table.add_row("remove", "Name", None, "Delete an installed plugin from the plugin folder")
case "search":
rich_table.add_row("search", "Name/all", None, "Search for a plugin and download the latest version")
case "update":
rich_table.add_row("update", "Name/all", None, "Update installed plugins to the latest version")
rich_table.add_row("update", "serverjar", None, "Update the installed serverjar to the latest version")
case _:
rich_print_error(f"[not bold]Error: Help for command [bright_magenta]'{command}' [bright_red]not found!")
rich_print_error("Use [bright_blue]'help all' [bright_red]to get a list of all commands.")
return None
rich_console.print(rich_table)
def check_for_pluGET_update() -> None:
"""
Check with the github api if there is a new version for pluGET available and print download message if this is