MCPcopy
hub / github.com/pocketbase/pocketbase / skipBootstrap

Method skipBootstrap

pocketbase.go:259–292  ·  view source on GitHub ↗

skipBootstrap eagerly checks if the app should skip the bootstrap process: - already bootstrapped - is unknown command - is the default help command - is the default version command https://github.com/pocketbase/pocketbase/issues/404 https://github.com/pocketbase/pocketbase/discussions/1267

()

Source from the content-addressed store, hash-verified

257// https://github.com/pocketbase/pocketbase/issues/404
258// https://github.com/pocketbase/pocketbase/discussions/1267
259func (pb *PocketBase) skipBootstrap() bool {
260 flags := []string{
261 "-h",
262 "--help",
263 "-v",
264 "--version",
265 }
266
267 if pb.IsBootstrapped() {
268 return true // already bootstrapped
269 }
270
271 cmd, _, err := pb.RootCmd.Find(os.Args[1:])
272 if err != nil {
273 return true // unknown command
274 }
275
276 for _, arg := range os.Args {
277 if !list.ExistInSlice(arg, flags) {
278 continue
279 }
280
281 // ensure that there is no user defined flag with the same name/shorthand
282 trimmed := strings.TrimLeft(arg, "-")
283 if len(trimmed) > 1 && cmd.Flags().Lookup(trimmed) == nil {
284 return true
285 }
286 if len(trimmed) == 1 && cmd.Flags().ShorthandLookup(trimmed) == nil {
287 return true
288 }
289 }
290
291 return false
292}
293
294// inspectRuntime tries to find the base executable directory and how it was run.
295//

Callers 2

ExecuteMethod · 0.95
TestSkipBootstrapFunction · 0.80

Calls 2

ExistInSliceFunction · 0.92
IsBootstrappedMethod · 0.65

Tested by 1

TestSkipBootstrapFunction · 0.64