MCPcopy Create free account
hub / github.com/gogs/gogs / adminDashboardOperation

Function adminDashboardOperation

internal/cmd/admin.go:169–189  ·  view source on GitHub ↗
(operation func() error, successMessage string)

Source from the content-addressed store, hash-verified

167}
168
169func adminDashboardOperation(operation func() error, successMessage string) func(*cli.Context) error {
170 return func(c *cli.Context) error {
171 err := conf.Init(c.String("config"))
172 if err != nil {
173 return errors.Wrap(err, "init configuration")
174 }
175 conf.InitLogging(true)
176
177 if _, err = database.SetEngine(); err != nil {
178 return errors.Wrap(err, "set engine")
179 }
180
181 if err := operation(); err != nil {
182 functionName := runtime.FuncForPC(reflect.ValueOf(operation).Pointer()).Name()
183 return errors.Newf("%s: %v", functionName, err)
184 }
185
186 fmt.Printf("%s\n", successMessage)
187 return nil
188 }
189}

Callers 1

admin.goFile · 0.85

Calls 6

InitFunction · 0.92
InitLoggingFunction · 0.92
SetEngineFunction · 0.92
PrintfMethod · 0.80
StringMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected