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 help=false
local sleep_seconds=$DEFAULT_SLEEP_SECONDS local sleep_seconds=$DEFAULT_SLEEP_SECONDS
local config="" local config=""
local start_proxy=false
local cmd=$0 local cmd=$0
# TODO --config is incompatible with --proxy, --bungee and standalone
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
local arg=$1 local arg=$1
case "$arg" in case "$arg" in
"--config" | "-c") "--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 shift 2
;; ;;
"--sleep" | "-s") "--sleep" | "-s")
@ -30,6 +43,8 @@ function main {
proxy=true proxy=true
if $bungee; then if $bungee; then
err "--proxy can't be used together with --bungee" err "--proxy can't be used together with --bungee"
elif [[ -n $config ]]; then
err "--proxy can't be used together with --config"
fi fi
shift shift
;; ;;
@ -37,6 +52,8 @@ function main {
bungee=true bungee=true
if $proxy; then if $proxy; then
err "--bungee can't be used together with --proxy" err "--bungee can't be used together with --proxy"
elif [[ -n $config ]]; then
err "--bungee can't be used together with --config"
fi fi
shift shift
;; ;;