From b2022fe687089d481dc70b5ceaa77ca78829be18 Mon Sep 17 00:00:00 2001 From: Leonard Steppy Date: Thu, 25 Dec 2025 22:47:19 +0100 Subject: [PATCH] Extract show_help function --- configure.sh | 36 ++++++++++++++++++++++-------------- start.sh | 32 ++++++++++++++++++++------------ 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/configure.sh b/configure.sh index 3b85013..b660bae 100755 --- a/configure.sh +++ b/configure.sh @@ -25,6 +25,26 @@ VIA_BACKWARDS_REPO="ViaVersion/ViaBackwards" 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] " + 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 { # parse arguments @@ -34,6 +54,7 @@ function main { local fetch=false local help=false + local cmd=$0 for arg in "$@"; do case "$arg" in "velocity") @@ -70,20 +91,7 @@ function main { done if $help; then - echo "Configure the server to be used with BungeeCord, Velcity or in standalone mode." - echo "" - echo "Usage: $0 [OPTIONS] " - 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 + show_help "$cmd" fi # fetch current configuration diff --git a/start.sh b/start.sh index 44e477e..89b8047 100755 --- a/start.sh +++ b/start.sh @@ -9,6 +9,25 @@ BUNGEE_DIR="bungee" # How many seconds to sleep before starting the server again, unless it is explicitly specified 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 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 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 { local proxy=false local bungee=false @@ -99,18 +118,7 @@ function main { fi if $help; then - 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 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 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 + show_help $cmd fi # Apply configuration