pulumi/pkg/util/cmdutil/console_password_windows.go
Pat Gavlin a23b10a9bf
Update the copyright end date to 2018. (#1068)
Just what it says on the tin.
2018-03-21 12:43:21 -07:00

28 lines
628 B
Go

// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
// +build windows
package cmdutil
import (
"fmt"
"github.com/bgentry/speakeasy"
"github.com/pulumi/pulumi/pkg/diag/colors"
)
// ReadConsoleNoEcho reads from the console without echoing. This is useful for reading passwords.
func ReadConsoleNoEcho(prompt string) (string, error) {
if prompt != "" {
prompt = colors.ColorizeText(
fmt.Sprintf("%s%s:%s ", colors.BrightCyan, prompt, colors.Reset))
fmt.Print(prompt)
}
s, err := speakeasy.Ask("")
fmt.Println() // echo a newline, since the user's keypress did not generate one
return s, err
}