diff --git a/cmd/urchin-admin/main.go b/cmd/urchin-admin/main.go index 5252ae0..271a7ba 100644 --- a/cmd/urchin-admin/main.go +++ b/cmd/urchin-admin/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "os" @@ -12,15 +13,30 @@ import ( ) func main() { - // sets zerolog as the main logger // in this APP common.SetupLogger() - app_settings, err := common.LoadSettings() - if err != nil { - log.Fatal().Msgf("could not load app settings: %v", err) - os.Exit(-1) + config_toml := flag.String("config", "", "path to config toml file") + flag.Parse() + + var app_settings common.AppSettings + if *config_toml != "" { + log.Info().Msgf("reading config file %s", *config_toml) + settings, err := common.ReadConfigToml(*config_toml) + if err != nil { + log.Error().Msgf("could not read toml: %v", err) + os.Exit(-2) + } + app_settings = settings + } else { + log.Info().Msgf("no config passed, reading environment variable settings") + settings, err := common.LoadSettings() + if err != nil { + log.Fatal().Msgf("could not load app settings: %v", err) + os.Exit(-1) + } + app_settings = settings } database, err := database.MakeSqlConnection(