feat: Cli.New(c) constructor — Core uses it during construction

Cli{}.New(c) replaces &Cli{core: c} in contract.go.
9 tests passing.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-24 19:26:44 +00:00
parent 85faedf6c0
commit f69be963bc
2 changed files with 8 additions and 1 deletions

7
cli.go
View file

@ -20,6 +20,13 @@ type Cli struct {
banner func(*Cli) string
}
// New creates a Cli bound to a Core instance.
//
// cli := core.Cli{}.New(c)
func (cl Cli) New(c *Core) *Cli {
return &Cli{core: c, output: os.Stdout}
}
// Print writes to the CLI output (defaults to os.Stdout).
//
// c.Cli().Print("hello %s", "world")

View file

@ -104,7 +104,7 @@ func New(opts ...CoreOption) Result {
commands: &commandRegistry{commands: make(map[string]*Command)},
}
c.context, c.cancel = context.WithCancel(context.Background())
c.cli = &Cli{core: c}
c.cli = Cli{}.New(c)
for _, opt := range opts {
if r := opt(c); !r.OK {