From 026553e4f87bfc647a5c03129752e30fc523fa07 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 6 Dec 2016 10:49:34 -0500 Subject: Improving command line interface (#4689) --- cmd/platform/init.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cmd/platform/init.go (limited to 'cmd/platform/init.go') diff --git a/cmd/platform/init.go b/cmd/platform/init.go new file mode 100644 index 000000000..7e07cce8a --- /dev/null +++ b/cmd/platform/init.go @@ -0,0 +1,41 @@ +package main + +import ( + "fmt" + + "github.com/mattermost/platform/api" + "github.com/mattermost/platform/utils" + "github.com/spf13/cobra" +) + +func doLoadConfig(filename string) (err string) { + defer func() { + if r := recover(); r != nil { + err = fmt.Sprintf("%v", r) + } + }() + utils.TranslationsPreInit() + utils.LoadConfig(filename) + return "" +} + +func initDBCommandContextCobra(cmd *cobra.Command) error { + config, err := cmd.Flags().GetString("config") + if err != nil { + return err + } + initDBCommandContext(config) + + return nil +} + +func initDBCommandContext(configFileLocation string) { + if errstr := doLoadConfig(configFileLocation); errstr != "" { + return + } + + utils.ConfigureCmdLineLog() + + api.NewServer() + api.InitStores() +} -- cgit v1.2.3-1-g7c22