hibiscus/flags.go

35 lines
656 B
Go
Raw Normal View History

2024-03-26 14:00:32 +03:00
package main
import (
"flag"
2024-03-26 18:26:34 +03:00
"log"
2024-03-26 14:00:32 +03:00
)
// FlagInit processes app flags.
2024-03-26 14:00:32 +03:00
func FlagInit() {
2024-03-26 18:26:34 +03:00
config := flag.String("config", "", "override config file")
2024-03-26 14:00:32 +03:00
username := flag.String("user", "", "override username")
password := flag.String("pass", "", "override password")
port := flag.Int("port", 0, "override port")
2024-05-04 14:29:49 +03:00
debug := flag.Bool("debug", false, "debug logging")
2024-03-26 14:00:32 +03:00
flag.Parse()
2024-03-26 18:26:34 +03:00
if *config != "" {
ConfigFile = *config
err := Cfg.Reload()
if err != nil {
log.Fatal(err)
}
}
2024-03-26 14:00:32 +03:00
if *username != "" {
Cfg.Username = *username
}
if *password != "" {
Cfg.Password = *password
}
if *port != 0 {
Cfg.Port = *port
}
2024-05-04 14:29:49 +03:00
DebugMode = *debug
2024-03-26 14:00:32 +03:00
}