assume prompts are required
parent
90808c1ce0
commit
add129826a
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue