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:
parent
85faedf6c0
commit
f69be963bc
2 changed files with 8 additions and 1 deletions
7
cli.go
7
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")
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue