terminal: rename PasswordPromptOutput -> TerminalOutput

Give it a more general name as it gets used for other terminal things
like progress output
This commit is contained in:
Carl Edquist 2022-10-06 01:23:50 -05:00
parent a716dc2533
commit 408d0c729b
3 changed files with 6 additions and 6 deletions

View File

@ -716,9 +716,9 @@ func checkPassword(password string) (string, error) {
// GetPassword asks the user for a password with the prompt given.
func GetPassword(prompt string) string {
_, _ = fmt.Fprintln(terminal.PasswordPromptOutput, prompt)
_, _ = fmt.Fprintln(terminal.TerminalOutput, prompt)
for {
_, _ = fmt.Fprint(terminal.PasswordPromptOutput, "password:")
_, _ = fmt.Fprint(terminal.TerminalOutput, "password:")
password := ReadPassword()
password, err := checkPassword(password)
if err == nil {

View File

@ -19,7 +19,7 @@ func redirectStderr(f *os.File) {
if err != nil {
log.Fatalf("Failed to duplicate stderr: %v", err)
}
terminal.PasswordPromptOutput = os.NewFile(uintptr(passPromptFd), "passPrompt")
terminal.TerminalOutput = os.NewFile(uintptr(passPromptFd), "passPrompt")
err = unix.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
if err != nil {
log.Fatalf("Failed to redirect stderr to file: %v", err)

View File

@ -69,14 +69,14 @@ var (
// make sure that start is only called once
once sync.Once
// PasswordPromptOutput is output of prompt for password
PasswordPromptOutput = os.Stderr
// TerminalOutput is for password prompt progress output
TerminalOutput = os.Stderr
)
// Start the terminal - must be called before use
func Start() {
once.Do(func() {
f := PasswordPromptOutput
f := TerminalOutput
if !IsTerminal(int(f.Fd())) {
// If output is not a tty then remove escape codes
Out = colorable.NewNonColorable(f)