aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorWilliam Hergès <anhgelus@anhgelus.world>2025-07-19 23:06:15 +0200
committerWilliam Hergès <anhgelus@anhgelus.world>2025-07-19 23:06:15 +0200
commitf009b61110d6e49952eb71e52685417c031d4038 (patch)
tree4fc552a85849a8a2c7cb5565b3b1e8ef0af448f3 /main.go
parente9e5325bf8c6fd26e528ea87c6953518f76563e3 (diff)
feat(cli): option to set port
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/main.go b/main.go
index 14432a1..4ef6f6d 100644
--- a/main.go
+++ b/main.go
@@ -23,17 +23,19 @@ var (
var (
domain string
configPath string
- dev bool
+ dev bool = false
generateToml bool
generateJson bool
+ port int = 80
)
func init() {
flag.StringVar(&domain, "domain", "", "domain to use")
flag.StringVar(&configPath, "config", "", "config to use")
- flag.BoolVar(&dev, "dev", false, "dev mode enabled")
+ flag.BoolVar(&dev, "dev", dev, "dev mode enabled")
flag.BoolVar(&generateJson, "generate-json-config", false, "generate a config example")
flag.BoolVar(&generateToml, "generate-toml-config", false, "generate a config example")
+ flag.IntVar(&port, "port", port, "set the port to use")
}
func main() {
@@ -125,11 +127,15 @@ func main() {
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
}
+ host := fmt.Sprintf(":%d", port)
if dev {
- slog.Info("Starting on http://localhost:8000/")
- g.StartServer(":8000")
+ if port != 80 {
+ g.StartServer(host)
+ } else {
+ g.StartServer(":8000")
+ }
} else {
- g.StartServer(":80")
+ g.StartServer(host)
}
}