feat: Core.Run() — ServiceStartup → Cli → ServiceShutdown lifecycle

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-24 21:32:50 +00:00
parent 7f4c4348c0
commit 7608808bb0

21
core.go
View file

@ -59,6 +59,27 @@ func (c *Core) Env(key string) string { return Env(key) }
func (c *Core) Context() context.Context { return c.context }
func (c *Core) Core() *Core { return c }
// --- Lifecycle ---
// Run starts all services, runs the CLI, then shuts down.
// This is the standard application lifecycle for CLI apps.
//
// c := core.New(core.WithService(myService.Register)).Value.(*Core)
// c.Run()
func (c *Core) Run() Result {
r := c.ServiceStartup(c.context, nil)
if !r.OK {
return r
}
if cli := c.Cli(); cli != nil {
r = cli.Run()
}
c.ServiceShutdown(c.context)
return r
}
// --- IPC (uppercase aliases) ---
func (c *Core) ACTION(msg Message) Result { return c.Action(msg) }