-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathshellrhythm
More file actions
executable file
·50 lines (43 loc) · 1.28 KB
/
shellrhythm
File metadata and controls
executable file
·50 lines (43 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env sh
# Hi! If you're curious, this is a bash file. It's made to be run on bash, the
# "shell" of Linux (i.e. the program that turns command lines into machine
# instructions).
# If you're on Windows, try running "run.bat" instead.
# So yeah, I'm sorry, import is a Linux exclusive... though you can run
# python3 ./src/import.py <url>
# as an alternative.
cd "$(dirname "$(realpath "$0")")"
if [ $# -eq 0 ]; then
python3 ./index.py
exit 0
fi
# Normalize arguments by removing the "--" prefix if it is present
ARG_PREFIX="$(echo "$1" | cut -c-2)"
if [ "$ARG_PREFIX" = "--" ]; then
ARG="$(echo "$1" | cut -c3-)"
else
ARG="$1"
fi
case "$ARG" in
"import")
echo "Attempting to import $2..."
python3 ./src/import.py $2 ;;
"update")
read -p "Do you want to update shellrhythm? [Y/n]: " yn
case $yn in
[Yy]*) git pull origin main ;;
[Nn]*) echo "Update aborted." ;;
esac ;;
"help")
cat <<EOF
Usage: shellrhythm [options]
A rhythm game, in the terminal!
Running without a command starts the game.
import url Imports an online chart.
update Checks for updates, then updates the game.
EOF
;;
*)
echo "Error: unknown command '$ARG'"
exit 1 ;;
esac