Skip to content

Commit 10315f4

Browse files
committed
fix(cli): stand up the cli primitive from the service
core.New no longer auto-registers the cli primitive, so cli.Register now registers it (via core.CliRegister) — registering the cli service IS a working CLI, driven by Core.Run() with no cli.Main wiring. cli.Init opts the primitive in via core.WithCli() so the cli.Main path keeps working. Co-Authored-By: Virgil <virgil@lethean.io>
1 parent 9777250 commit 10315f4

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

go/pkg/cli/runtime.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ func Init(opts Options) core.Result {
7070

7171
ctx, cancel := context.WithCancel(context.Background())
7272

73-
// Create Core instance with CLI service (registered automatically by core.New)
73+
// Create Core instance + opt in the CLI primitive (core.New no longer
74+
// auto-registers it).
7475
c := core.New(
7576
core.WithOption("name", opts.AppName),
77+
core.WithCli(),
7678
)
7779
c.App().Name = opts.AppName
7880
c.App().Version = opts.Version

go/pkg/cli/service.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,22 @@ func NewService(config CliConfig) func(*core.Core) core.Result {
5555
//
5656
// Usage example: `r := cli.Register(c); svc := r.Value.(*cli.Service)`
5757
func Register(c *core.Core) core.Result {
58-
return NewService(CliConfig{})(c)
58+
// Stand up the actual CLI surface — register the *core.Cli command
59+
// primitive so c.Cli() resolves and Core.Run() drives it (ServiceStartup →
60+
// cli.Run() → ServiceShutdown). Registering this service IS adding a
61+
// working CLI; it composes like any other Core service — no cli.Main.
62+
if r := core.CliRegister(c); !r.OK {
63+
return r
64+
}
65+
r := NewService(CliConfig{})(c)
66+
if !r.OK {
67+
return r
68+
}
69+
svc := r.Value.(*Service)
70+
c.Action("cli.version", svc.handleVersion)
71+
c.Action("cli.app_name", svc.handleAppName)
72+
c.Action("cli.build_info", svc.handleBuildInfo)
73+
return core.Ok(nil)
5974
}
6075

6176
// OnStartup registers the cli action handlers on the attached Core.

0 commit comments

Comments
 (0)