hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/internal/cli/cli.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli/cli.go')
-rw-r--r--internal/cli/cli.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go
index 4f98b6d..243dc80 100644
--- a/internal/cli/cli.go
+++ b/internal/cli/cli.go
@@ -8,6 +8,7 @@ import (
"github.com/charmbracelet/bubbles/spinner"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
+ "github.com/charmbracelet/huh"
"github.com/charmbracelet/lipgloss"
"github.com/hachem-wtf/benson/internal/config"
@@ -37,7 +38,14 @@ type model struct {
quitting bool
events chan tea.Msg
- width int
+ form *huh.Form
+ pickerStage int
+ pickerAction string
+ pickerQuery string
+ pickerSlug string
+ pickerVersion string
+
+ width, height int
}
func Run(version string) error {
@@ -88,9 +96,13 @@ func (m *model) Init() tea.Cmd {
}
func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+ if m.form != nil {
+ return m.updatePicker(msg)
+ }
+
switch msg := msg.(type) {
case tea.WindowSizeMsg:
- m.width = msg.Width
+ m.width, m.height = msg.Width, msg.Height
m.input.Width = max(msg.Width-12, 20)
return m, nil
@@ -116,6 +128,10 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.busy = false
return m, tea.Println(msg.text)
+ case modManagerMsg:
+ m.busy = false
+ return m, m.handleModManager(msg)
+
case streamMsg:
return m, tea.Sequence(tea.Println(msg.text), waitForEvent(m.events))
@@ -145,6 +161,9 @@ func (m *model) View() string {
if m.quitting {
return ""
}
+ if m.form != nil {
+ return "\n" + m.form.View() + "\n"
+ }
return "\n" + m.suggestionRow() + "\n" + m.promptLine() + "\n"
}