Improving command line interface (#4689)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dcf11a14d8
Коммит
026553e4f8
41
cmd/platform/init.go
Обычный файл
41
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()
|
||||
}
|
||||
Ссылка в новой задаче
Block a user