summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaas Lalani <maas@lalani.dev>2024-03-28 16:36:14 -0400
committerMaas Lalani <maas@lalani.dev>2024-03-28 16:36:14 -0400
commit589be38936fcdaca71b1aa3ab8017138555a2a69 (patch)
tree7686c335d9471d315ef9e66d092e5e0fa0a46679
parent4a560b19534839674fd92bcbad0aa4ee7158b926 (diff)
fix: textinput stdin read
-rw-r--r--input/command.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/input/command.go b/input/command.go
index 60a9743..b4a77e3 100644
--- a/input/command.go
+++ b/input/command.go
@@ -2,8 +2,9 @@ package input
import (
"fmt"
+ "os"
- "github.com/charmbracelet/bubbles/textinput"
+ tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/huh"
"github.com/charmbracelet/lipgloss"
@@ -13,21 +14,21 @@ import (
// Run provides a shell script interface for the text input bubble.
// https://github.com/charmbracelet/bubbles/textinput
func (o Options) Run() error {
- i := textinput.New()
+
+ var value string
if o.Value != "" {
- i.SetValue(o.Value)
+ value = o.Value
} else if in, _ := stdin.Read(); in != "" {
- i.SetValue(in)
+ value = in
}
theme := huh.ThemeCharm()
theme.Focused.Base = lipgloss.NewStyle()
- theme.Focused.TextInput.Cursor = o.CursorStyle.ToLipgloss()
+ // theme.Focused.TextInput.Cursor = o.CursorStyle.ToLipgloss()
theme.Focused.TextInput.Placeholder = o.PlaceholderStyle.ToLipgloss()
theme.Focused.TextInput.Prompt = o.PromptStyle.ToLipgloss()
theme.Focused.Title = o.HeaderStyle.ToLipgloss()
- var value string
var echoMode huh.EchoMode
if o.Password {
@@ -49,6 +50,7 @@ func (o Options) Run() error {
).
WithShowHelp(false).
WithTheme(theme).
+ WithProgramOptions(tea.WithOutput(os.Stderr)).
Run()
if err != nil {