Skip to content

Commit

Permalink
fix: textinput stdin read
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Mar 28, 2024
1 parent 4a560b1 commit 589be38
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions input/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 {

Check failure on line 16 in input/command.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)
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 {
Expand All @@ -49,6 +50,7 @@ func (o Options) Run() error {
).
WithShowHelp(false).
WithTheme(theme).
WithProgramOptions(tea.WithOutput(os.Stderr)).
Run()

if err != nil {
Expand Down

0 comments on commit 589be38

Please sign in to comment.