2024-10-21 16:46:25 +03:00
|
|
|
package app
|
2024-03-26 14:00:32 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
2024-03-26 18:26:34 +03:00
|
|
|
"log"
|
2024-10-21 16:46:25 +03:00
|
|
|
|
|
|
|
"git.a71.su/Andrew71/hibiscus-txt/internal/config"
|
|
|
|
"git.a71.su/Andrew71/hibiscus-txt/internal/logging"
|
2024-03-26 14:00:32 +03:00
|
|
|
)
|
|
|
|
|
2024-06-17 00:54:55 +03:00
|
|
|
// FlagInit processes app flags.
|
2024-03-26 14:00:32 +03:00
|
|
|
func FlagInit() {
|
2024-10-21 16:46:25 +03:00
|
|
|
conf := 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-10-21 16:46:25 +03:00
|
|
|
if *conf != "" {
|
|
|
|
config.ConfigFile = *conf
|
|
|
|
err := config.Cfg.Reload()
|
2024-03-26 18:26:34 +03:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2024-03-26 14:00:32 +03:00
|
|
|
if *username != "" {
|
2024-10-21 16:46:25 +03:00
|
|
|
config.Cfg.Username = *username
|
2024-03-26 14:00:32 +03:00
|
|
|
}
|
|
|
|
if *password != "" {
|
2024-10-21 16:46:25 +03:00
|
|
|
config.Cfg.Password = *password
|
2024-03-26 14:00:32 +03:00
|
|
|
}
|
|
|
|
if *port != 0 {
|
2024-10-21 16:46:25 +03:00
|
|
|
config.Cfg.Port = *port
|
2024-03-26 14:00:32 +03:00
|
|
|
}
|
2024-10-21 16:46:25 +03:00
|
|
|
logging.DebugMode = *debug
|
2024-03-26 14:00:32 +03:00
|
|
|
}
|