Skip to content

Commit 42a566a

Browse files
committed
fix: use comma-separated list of ports
1 parent 5f74912 commit 42a566a

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

balatro.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ esac
3131
show_usage() {
3232
cat <<EOF
3333
Usage: $0 [OPTIONS]
34-
$0 -p PORT [OPTIONS]
34+
$0 --ports PORT1,PORT2,... [OPTIONS]
3535
$0 --kill
3636
$0 --status
3737
3838
Options:
39-
-p, --port PORT Specify port for Balatro instance (can be used multiple times)
40-
Default: 12346 if no port specified
39+
--ports PORTS Comma-separated list of ports for Balatro instances
40+
Default: 12346 if not specified
4141
--headless Enable headless mode (sets BALATROBOT_HEADLESS=1)
4242
--fast Enable fast mode (sets BALATROBOT_FAST=1)
4343
--audio Enable audio (disabled by default, sets BALATROBOT_AUDIO=1)
@@ -49,8 +49,8 @@ Options:
4949
5050
Examples:
5151
$0 # Start single instance on default port 12346
52-
$0 -p 12347 # Start single instance on port 12347
53-
$0 -p 12346 -p 12347 # Start two instances on ports 12346 and 12347
52+
$0 --ports 12347 # Start single instance on port 12347
53+
$0 --ports 12346,12347 # Start two instances on ports 12346 and 12347
5454
$0 --headless --fast # Start with headless and fast mode on default port
5555
$0 --audio # Start with audio enabled on default port
5656
$0 --render-on-api # Start with on-demand rendering on default port
@@ -64,16 +64,19 @@ EOF
6464
parse_arguments() {
6565
while [[ $# -gt 0 ]]; do
6666
case $1 in
67-
-p | --port)
67+
--ports)
6868
if [[ -z "$2" ]] || [[ "$2" =~ ^- ]]; then
69-
echo "Error: --port requires a port number" >&2
69+
echo "Error: --ports requires a comma-separated list of ports" >&2
7070
exit 1
7171
fi
72-
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -lt 1024 ]] || [[ "$2" -gt 65535 ]]; then
73-
echo "Error: Port must be a number between 1024 and 65535" >&2
74-
exit 1
75-
fi
76-
PORTS+=("$2")
72+
IFS=',' read -ra port_list <<< "$2"
73+
for port in "${port_list[@]}"; do
74+
if ! [[ "$port" =~ ^[0-9]+$ ]] || [[ "$port" -lt 1024 ]] || [[ "$port" -gt 65535 ]]; then
75+
echo "Error: Port must be a number between 1024 and 65535 (got: $port)" >&2
76+
exit 1
77+
fi
78+
PORTS+=("$port")
79+
done
7780
shift 2
7881
;;
7982
--headless)

0 commit comments

Comments
 (0)