forked from tildetown/town
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) {
|
||||
fmt.Println("")
|
||||
fmt.Println(p.cs.Prompt(prompt))
|
||||
fmt.Println(p.cs.Subtitle("(press enter to submit)"))
|
||||
s, err := p.tty.ReadString()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("couldn't collect input: %w", err)
|
||||
// TODO assumes blank is no bueno
|
||||
|
||||
var err error
|
||||
var answer string
|
||||
for answer == "" {
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue