22 lines
280 B
Go
22 lines
280 B
Go
|
package prompt
|
||
|
|
||
|
import (
|
||
|
"bufio"
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func StringPrompt(label string) string {
|
||
|
var s string
|
||
|
r := bufio.NewReader(os.Stdin)
|
||
|
for {
|
||
|
fmt.Fprint(os.Stderr, label+" ")
|
||
|
s, _ = r.ReadString('\n')
|
||
|
if s != "" {
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
return strings.TrimSpace(s)
|
||
|
}
|