This commit is contained in:
2024-06-23 09:49:14 -05:00
parent 716b7424c4
commit d96fae1276
13 changed files with 810 additions and 568 deletions

44
internal/tui/helper.go Normal file
View 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
}