assume prompts are required

trunk
vilmibm 2023-10-26 22:32:30 +00:00
parent 90808c1ce0
commit add129826a
1 changed files with 13 additions and 7 deletions

View File

@ -72,15 +72,21 @@ func NewPrompter(tty *tty.TTY, cs colorScheme) *Prompter {
} }
func (p *Prompter) String(prompt string) (string, error) { func (p *Prompter) String(prompt string) (string, error) {
fmt.Println("") // TODO assumes blank is no bueno
fmt.Println(p.cs.Prompt(prompt))
fmt.Println(p.cs.Subtitle("(press enter to submit)")) var err error
s, err := p.tty.ReadString() var answer string
if err != nil { for answer == "" {
return "", fmt.Errorf("couldn't collect input: %w", err) fmt.Println("")
fmt.Println(p.cs.Prompt(prompt))
fmt.Println(p.cs.Subtitle("(press enter to submit)"))
answer, err = p.tty.ReadString()
if err != nil {
return "", fmt.Errorf("couldn't collect input: %w", err)
}
} }
return s, nil return answer, nil
} }
func (p *Prompter) Select(prompt string, opts []string) (int, error) { func (p *Prompter) Select(prompt string, opts []string) (int, error) {