From f69be963bc9648d9d8f5e083b510b85b37087fa6 Mon Sep 17 00:00:00 2001 From: Snider Date: Tue, 24 Mar 2026 19:26:44 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20Cli.New(c)=20constructor=20=E2=80=94=20?= =?UTF-8?q?Core=20uses=20it=20during=20construction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cli{}.New(c) replaces &Cli{core: c} in contract.go. 9 tests passing. Co-Authored-By: Virgil --- cli.go | 7 +++++++ contract.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cli.go b/cli.go index c8371a3..8a292d0 100644 --- a/cli.go +++ b/cli.go @@ -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") diff --git a/contract.go b/contract.go index 43b82c0..e5a9be3 100644 --- a/contract.go +++ b/contract.go @@ -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 {