Skip to content

Commit 404b748

Browse files
committed
fix: use comma-separated ports in balatro.sh
1 parent dbe4a95 commit 404b748

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

balatro.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ esac
3030
show_usage() {
3131
cat <<EOF
3232
Usage: $0 [OPTIONS]
33-
$0 -p PORT [OPTIONS]
33+
$0 --ports PORTS [OPTIONS]
3434
$0 --kill
3535
$0 --status
3636
3737
Options:
38-
-p, --port PORT Specify port for Balatro instance (can be used multiple times)
39-
Default: 12346 if no port specified
38+
--ports PORTS Comma-separated list of ports (e.g., 12346,12347)
39+
Default: 12346 if not specified
4040
--headless Enable headless mode (sets BALATROBOT_HEADLESS=1)
4141
--fast Enable fast mode (sets BALATROBOT_FAST=1)
4242
--audio Enable audio (disabled by default, sets BALATROBOT_AUDIO=1)
@@ -46,8 +46,8 @@ Options:
4646
4747
Examples:
4848
$0 # Start single instance on default port 12346
49-
$0 -p 12347 # Start single instance on port 12347
50-
$0 -p 12346 -p 12347 # Start two instances on ports 12346 and 12347
49+
$0 --ports 12347 # Start single instance on port 12347
50+
$0 --ports 12346,12347 # Start two instances on ports 12346 and 12347
5151
$0 --headless --fast # Start with headless and fast mode on default port
5252
$0 --audio # Start with audio enabled on default port
5353
$0 --kill # Kill all running Balatro instances
@@ -60,16 +60,20 @@ EOF
6060
parse_arguments() {
6161
while [[ $# -gt 0 ]]; do
6262
case $1 in
63-
-p | --port)
63+
--ports)
6464
if [[ -z "$2" ]] || [[ "$2" =~ ^- ]]; then
65-
echo "Error: --port requires a port number" >&2
65+
echo "Error: --ports requires comma-separated port numbers" >&2
6666
exit 1
6767
fi
68-
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -lt 1024 ]] || [[ "$2" -gt 65535 ]]; then
69-
echo "Error: Port must be a number between 1024 and 65535" >&2
70-
exit 1
71-
fi
72-
PORTS+=("$2")
68+
# Split comma-separated ports into array
69+
IFS=',' read -ra port_list <<< "$2"
70+
for port in "${port_list[@]}"; do
71+
if ! [[ "$port" =~ ^[0-9]+$ ]] || [[ "$port" -lt 1024 ]] || [[ "$port" -gt 65535 ]]; then
72+
echo "Error: Port must be a number between 1024 and 65535" >&2
73+
exit 1
74+
fi
75+
PORTS+=("$port")
76+
done
7377
shift 2
7478
;;
7579
--headless)

0 commit comments

Comments
 (0)