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 {