mirror of
https://codeberg.org/bunbun/bunbun.dev
synced 2025-06-07 21:39:50 -07:00
added arguments and support for running locally
This commit is contained in:
25
arg-handler.fnl
Normal file
25
arg-handler.fnl
Normal file
@ -0,0 +1,25 @@
|
||||
(set _G.port 50625)
|
||||
(set _G.use-http false)
|
||||
|
||||
(local usage (: "Usage: %s [-h] [-p] [--use-http]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message and exit
|
||||
-p, --port Set the port number for the server. Don't change this
|
||||
unless you're running the server locally
|
||||
--use-http Use http instead of https. Only recommended when running
|
||||
the server locally
|
||||
|
||||
" :format (. arg 0)))
|
||||
|
||||
(for [i 1 (length arg)]
|
||||
(tset arg i (: (. arg i) :gsub "^%-+" ""))
|
||||
(if (or (= (. arg i) :h) (= (. arg i) :help))
|
||||
(do
|
||||
(print usage)
|
||||
(os.exit))
|
||||
(or (= (. arg i) :p) (= (. arg i) :port))
|
||||
(do
|
||||
(set _G.port (. arg (+ i 1)))
|
||||
(set-forcibly! i (+ i 1)))
|
||||
(= (. arg i) :use-http) (set _G.use-http true)))
|
Reference in New Issue
Block a user