style(config): add structured config paths for global and bot configurations
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
agent.md
|
agent.md
|
||||||
config.json
|
config.json
|
||||||
bot_user_config.json
|
bot_user_config.json
|
||||||
|
bot_node_config.json
|
||||||
*.exe
|
*.exe
|
||||||
nukumizu-linux-amd64
|
nukumizu-linux-amd64
|
||||||
|
|
||||||
|
|||||||
@@ -22,3 +22,15 @@ var SoftwareInfo = SoftwareInfoStr{
|
|||||||
BuildType: "Debug",
|
BuildType: "Debug",
|
||||||
BuildTime: "unknown",
|
BuildTime: "unknown",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ConfigPathStr struct {
|
||||||
|
Global string
|
||||||
|
BotUserConfig string
|
||||||
|
BotNodeConfig string
|
||||||
|
}
|
||||||
|
|
||||||
|
var ConfigPath = ConfigPathStr{
|
||||||
|
Global: "config.json",
|
||||||
|
BotUserConfig: "bot_user_config.json",
|
||||||
|
BotNodeConfig: "bot_node_config.json",
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -34,21 +33,16 @@ func main() {
|
|||||||
global.SoftwareInfo.CommitHash = CommitHash
|
global.SoftwareInfo.CommitHash = CommitHash
|
||||||
global.SoftwareInfo.BuildTime = BuildTime
|
global.SoftwareInfo.BuildTime = BuildTime
|
||||||
|
|
||||||
// Parse CLI flags.
|
|
||||||
configPath_global := flag.String("config", "config.json", "Path to configuration file")
|
|
||||||
configPath_bot_user := flag.String("bot-user-config", "bot_user_config.json", "Path to bot user configuration file")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
// Log startup banner.
|
// Log startup banner.
|
||||||
postLog.Info(fmt.Sprintf("%s Ver.%s.%d.%s.%s Developed by %s at %s", global.SoftwareInfo.Name, global.SoftwareInfo.Version, global.SoftwareInfo.BuildVer, global.SoftwareInfo.BuildType, global.SoftwareInfo.CommitHash, global.SoftwareInfo.Developer, global.SoftwareInfo.BuildTime))
|
postLog.Info(fmt.Sprintf("%s Ver.%s.%d.%s.%s Developed by %s at %s", global.SoftwareInfo.Name, global.SoftwareInfo.Version, global.SoftwareInfo.BuildVer, global.SoftwareInfo.BuildType, global.SoftwareInfo.CommitHash, global.SoftwareInfo.Developer, global.SoftwareInfo.BuildTime))
|
||||||
|
|
||||||
// Load configuration.
|
// Load configuration.
|
||||||
cfg, err := config.LoadGlobalConfig(*configPath_global)
|
cfg, err := config.LoadGlobalConfig(global.ConfigPath.Global)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to load global config: %v", err)
|
log.Fatalf("Failed to load global config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = config.LoadBotUserConfig(*configPath_bot_user)
|
_, err = config.LoadBotUserConfig(global.ConfigPath.BotUserConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to load bot user config: %v", err)
|
log.Fatalf("Failed to load bot user config: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user