From 72ba6ff67d3684d7f68130ba7dec88ddc0a2dbe6 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 28 Nov 2017 17:29:42 +0100 Subject: [PATCH] Better organization for config options --- midgaard_bot.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/midgaard_bot.go b/midgaard_bot.go index 26278aa..ce92e73 100644 --- a/midgaard_bot.go +++ b/midgaard_bot.go @@ -27,12 +27,21 @@ import ( "github.com/jessevdk/go-flags" ) -var config struct { +type TelegramConfig struct { Token string `short:"t" long:"token" description:"Telegram API Token" required:"true"` } +type MercConfig struct { + Host string `short:"h" long:"host" description:"Host and port for Merc MUD" required:"true"` +} + +var Config struct { + Telegram TelegramConfig `group:"Telegram config"` + Merc MercConfig `group:"Merc MUD config"` +} + func main() { - _, err := flags.Parse(&config) + _, err := flags.Parse(&Config) if err != nil { log.Panic(err) } @@ -45,7 +54,7 @@ func main() { log.Panic(err) } - err = initTelegramWorkers(config.Token, ctx) + err = initTelegramWorkers(Config.Telegram.Token, ctx) if err != nil { log.Panic(err) } -- 2.39.5