update
This commit is contained in:
44
internal/tui/helper.go
Normal file
44
internal/tui/helper.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type Boa struct {
|
||||
options *options
|
||||
}
|
||||
|
||||
// Create a new instance of Boa with custom Options
|
||||
func New(options ...Options) *Boa {
|
||||
opts := defaultOptions()
|
||||
for _, opt := range options {
|
||||
opt.apply(opts)
|
||||
}
|
||||
return &Boa{
|
||||
options: opts,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Boa) HelpFunc(cmd *cobra.Command, s []string) {
|
||||
model := newCmdModel(b.options, cmd)
|
||||
p := tea.NewProgram(model, b.options.altScreen, b.options.mouseCellMotion)
|
||||
p.Run()
|
||||
|
||||
if model.print {
|
||||
fmt.Println(b.options.styles.Border.Render(b.options.styles.CmdPrint.Render(model.cmdChain)))
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Boa) UsageFunc(cmd *cobra.Command) error {
|
||||
model := newCmdModel(b.options, cmd)
|
||||
p := tea.NewProgram(model, b.options.altScreen, b.options.mouseCellMotion)
|
||||
p.Run()
|
||||
|
||||
if model.print {
|
||||
fmt.Println(b.options.styles.Border.Render(b.options.styles.CmdPrint.Render(model.cmdChain)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user