added arguments and support for running locally

This commit is contained in:
2024-07-12 14:26:42 -07:00
parent 9a0c639c96
commit 48aab27d60
4 changed files with 38 additions and 5 deletions

View File

@ -1,14 +1,15 @@
#!/bin/bash
command="fennel main.fnl"
command="./main.fnl"
kill_command="pkill -f 'main\.fnl'"
log_file="log"
usage="Usage: start-server [-h] [-l] [--log-file] [-k]
usage="Usage: start-server [-h] [--localhost] [-l] [--log-file] [-k]
Options:
-h, --help Show this help message and exit
--localhost Run the server locally
-l, --log Log requests in the log file
--log-file Set the log file
-k, --kill Kill the server and exit
@ -19,6 +20,8 @@ for (( i=1; i<=$#; i++ )); do
if [[ "${!i}" == "-h" || "${!i}" == "--help" ]]; then
printf "$usage"
exit 0
elif [[ "${!i}" == "--localhost" ]]; then
command="${command} --port 8080 --use-http"
elif [[ "${!i}" == "-l" || "${!i}" == "--log" ]]; then
command="${command} | tee ${log_file}"
elif [[ "${!i}" == "--log-file" ]]; then