Ensure mode is valid and config parameter is incompatible with proxy and bungee parameters

This commit is contained in:
Leonard Steppy 2025-12-25 19:22:14 +01:00
parent 3e0ace43d2
commit 95f5d293bf

View File

@ -11,15 +11,28 @@ function main {
local help=false
local sleep_seconds=$DEFAULT_SLEEP_SECONDS
local config=""
local start_proxy=false
local cmd=$0
# TODO --config is incompatible with --proxy, --bungee and standalone
while [ $# -gt 0 ]; do
local arg=$1
case "$arg" in
"--config" | "-c")
config=$2 #TODO ensure mode is valid
local mode=$2
case "$mode" in
"proxy" | "bungee" | "standalone")
;;
case *)
err "Invalid mode for --config: $mode"
;;
esac
config=$mode
if $proxy; then
err "--config can't be used together with --proxy"
elif $bungee; then
err "--config can't be used together with --bungee"
fi
shift 2
;;
"--sleep" | "-s")
@ -30,6 +43,8 @@ function main {
proxy=true
if $bungee; then
err "--proxy can't be used together with --bungee"
elif [[ -n $config ]]; then
err "--proxy can't be used together with --config"
fi
shift
;;
@ -37,6 +52,8 @@ function main {
bungee=true
if $proxy; then
err "--bungee can't be used together with --proxy"
elif [[ -n $config ]]; then
err "--bungee can't be used together with --config"
fi
shift
;;