these realistically shouldn't error anyway? and if they do, bye
This commit is contained in:
parent
ba20b23767
commit
a8978790eb
|
@ -3,6 +3,7 @@ package prompt
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
@ -15,15 +16,14 @@ func YesNo(prompt string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AskRune(prompt, options string) byte {
|
func AskRune(prompt, options string) byte {
|
||||||
// TODO: handle errors better
|
|
||||||
// switch stdin into 'raw' mode
|
// switch stdin into 'raw' mode
|
||||||
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := term.Restore(int(os.Stdin.Fd()), oldState); err != nil {
|
if err := term.Restore(int(os.Stdin.Fd()), oldState); err != nil {
|
||||||
panic(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue