feat(cli): option to set port
This commit is contained in:
parent
e9e5325bf8
commit
f009b61110
1 changed files with 11 additions and 5 deletions
16
main.go
16
main.go
|
@ -23,17 +23,19 @@ var (
|
||||||
var (
|
var (
|
||||||
domain string
|
domain string
|
||||||
configPath string
|
configPath string
|
||||||
dev bool
|
dev bool = false
|
||||||
generateToml bool
|
generateToml bool
|
||||||
generateJson bool
|
generateJson bool
|
||||||
|
port int = 80
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.StringVar(&domain, "domain", "", "domain to use")
|
flag.StringVar(&domain, "domain", "", "domain to use")
|
||||||
flag.StringVar(&configPath, "config", "", "config 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(&generateJson, "generate-json-config", false, "generate a config example")
|
||||||
flag.BoolVar(&generateToml, "generate-toml-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() {
|
func main() {
|
||||||
|
@ -125,11 +127,15 @@ func main() {
|
||||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
host := fmt.Sprintf(":%d", port)
|
||||||
if dev {
|
if dev {
|
||||||
slog.Info("Starting on http://localhost:8000/")
|
if port != 80 {
|
||||||
g.StartServer(":8000")
|
g.StartServer(host)
|
||||||
} else {
|
} else {
|
||||||
g.StartServer(":80")
|
g.StartServer(":8000")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g.StartServer(host)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue