Refactor everything
This commit is contained in:
parent
b56ce43c80
commit
57903d4724
45 changed files with 514 additions and 416 deletions
37
internal/app/flags.go
Normal file
37
internal/app/flags.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"git.a71.su/Andrew71/hibiscus-txt/internal/config"
|
||||
"git.a71.su/Andrew71/hibiscus-txt/internal/logging"
|
||||
)
|
||||
|
||||
// FlagInit processes app flags.
|
||||
func FlagInit() {
|
||||
conf := flag.String("config", "", "override config file")
|
||||
username := flag.String("user", "", "override username")
|
||||
password := flag.String("pass", "", "override password")
|
||||
port := flag.Int("port", 0, "override port")
|
||||
debug := flag.Bool("debug", false, "debug logging")
|
||||
|
||||
flag.Parse()
|
||||
if *conf != "" {
|
||||
config.ConfigFile = *conf
|
||||
err := config.Cfg.Reload()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
if *username != "" {
|
||||
config.Cfg.Username = *username
|
||||
}
|
||||
if *password != "" {
|
||||
config.Cfg.Password = *password
|
||||
}
|
||||
if *port != 0 {
|
||||
config.Cfg.Port = *port
|
||||
}
|
||||
logging.DebugMode = *debug
|
||||
}
|
12
internal/app/main.go
Normal file
12
internal/app/main.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"git.a71.su/Andrew71/hibiscus-txt/internal/logging"
|
||||
"git.a71.su/Andrew71/hibiscus-txt/internal/server"
|
||||
)
|
||||
|
||||
func Execute() {
|
||||
FlagInit()
|
||||
logging.LogInit()
|
||||
server.Serve()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue