boot v2 progress: disks, ssh, success...

This commit is contained in:
Mikaël Cluseau
2022-03-08 11:45:56 +01:00
parent 8e86579004
commit 8506f8807d
38 changed files with 1767 additions and 113 deletions

43
ask-secret.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
"bufio"
"bytes"
"io"
"os"
)
func askSecret(prompt string) []byte {
stdinTTY.EchoOff()
var (
in io.Reader = stdin
out io.Writer = stdout
)
if stdin == nil {
in = os.Stdin
out = os.Stdout
}
out.Write([]byte(prompt + ": "))
if stdin != nil {
stdout.HideInput()
}
s, err := bufio.NewReader(in).ReadBytes('\n')
if stdin != nil {
stdout.ShowInput()
}
stdinTTY.Restore()
if err != nil {
fatalf("failed to read from stdin: %v", err)
}
s = bytes.TrimRight(s, "\r\n")
return s
}