Extract show_help function

This commit is contained in:
Leonard Steppy 2025-12-25 22:47:19 +01:00
parent 6e6b42f54a
commit b2022fe687
2 changed files with 42 additions and 26 deletions

View File

@ -25,6 +25,26 @@ VIA_BACKWARDS_REPO="ViaVersion/ViaBackwards"
quiet=false quiet=false
function show_help {
local cmd=$0
echo "Configure the server to be used with BungeeCord, Velcity or in standalone mode."
echo ""
echo "Usage: $cmd [OPTIONS] <mode>"
echo ""
echo "mode:"
echo " velocity"
echo " bungeecord"
echo " standalone"
echo ""
echo "OPTIONS:"
echo " --fetch Print the current mode before reconfiguring the server. Nothing else will be printed."
echo " -h --help Show this message"
echo " -q --quiet Don't print any output, except for output which is caused by --fetch"
exit
}
function main { function main {
# parse arguments # parse arguments
@ -34,6 +54,7 @@ function main {
local fetch=false local fetch=false
local help=false local help=false
local cmd=$0
for arg in "$@"; do for arg in "$@"; do
case "$arg" in case "$arg" in
"velocity") "velocity")
@ -70,20 +91,7 @@ function main {
done done
if $help; then if $help; then
echo "Configure the server to be used with BungeeCord, Velcity or in standalone mode." show_help "$cmd"
echo ""
echo "Usage: $0 [OPTIONS] <mode>"
echo ""
echo "mode:"
echo " velocity"
echo " bungeecord"
echo " standalone"
echo ""
echo "OPTIONS:"
echo " --fetch Print the current mode before reconfiguring the server. Nothing else will be printed."
echo " -h --help Show this message"
echo " -q --quiet Don't print any output, except for output which is caused by --fetch"
exit 0
fi fi
# fetch current configuration # fetch current configuration

View File

@ -9,6 +9,25 @@ BUNGEE_DIR="bungee"
# How many seconds to sleep before starting the server again, unless it is explicitly specified # How many seconds to sleep before starting the server again, unless it is explicitly specified
DEFAULT_SLEEP_SECONDS=3 DEFAULT_SLEEP_SECONDS=3
function show_help {
local cmd=$0
echo "Create a start loop for the minecraft server, additionally behind a velocity proxy or bungeecord proxy"
echo ""
echo "Usage $cmd [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " -c --config <mode> How to configure the server (see ./configure.sh --help). Possible values for mode are: proxy, bungee, standalone"
echo " -t --temp --tmp Apply the configuration only temporary, while the server is running. Requires --config."
echo " -s --sleep <secs> How many seconds to sleep after the server has stopped before starting it again"
echo " -h --help Show help"
echo " --proxy Start the server behind a velocity proxy"
echo " --bungee Start the server behind a bungeecord proxy"
exit
}
function main { function main {
local proxy=false local proxy=false
local bungee=false local bungee=false
@ -99,18 +118,7 @@ function main {
fi fi
if $help; then if $help; then
echo "Create a start loop for the minecraft server, additionally behind a velocity proxy or bungeecord proxy" show_help $cmd
echo ""
echo "Usage $cmd [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " -c --config <mode> How to configure the server (see ./configure.sh --help). Possible values for mode are: proxy, bungee, standalone"
echo " -t --temp --tmp Apply the configuration only temporary, while the server is running. Requires --config."
echo " -s --sleep <secs> How many seconds to sleep after the server has stopped before starting it again"
echo " -h --help Show help"
echo " --proxy Start the server behind a velocity proxy"
echo " --bungee Start the server behind a bungeecord proxy"
exit
fi fi
# Apply configuration # Apply configuration