mirror of
https://github.com/rclone/rclone.git
synced 2025-03-09 21:05:28 +01:00
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:
parent
a716dc2533
commit
408d0c729b
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user