diff options
| author | hachem <im@hachem.wtf> | 2026-08-29 18:24:42 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-29 18:24:42 +0200 |
| commit | fcbbeccaa80c7e120933682b330272a1490c1cf5 (patch) | |
| tree | 11de4610f01a3861f7bbea94da63dd2d070f420a /internal/cli/cli.go | |
| parent | 4806ee7ef95f0f04079856f7753399b7b7aa6330 (diff) | |
refactor: unify mods command with the search
Diffstat (limited to 'internal/cli/cli.go')
| -rw-r--r-- | internal/cli/cli.go | 23 |
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" } |
