1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 02:23:24 +00:00

config, terminal: move PasswordPromptOutput from config to terminal

First, move this variable in order to avoid circular imports between
config and terminal.  (config already depends on terminal.)

But also, it seems PasswordPromptOutput conceptually fits well in
terminal, as the idea is for it to store the output for the terminal.
This commit is contained in:
Carl Edquist
2022-10-06 00:27:21 -05:00
parent 28f0c08a98
commit a716dc2533
4 changed files with 8 additions and 10 deletions

View File

@@ -8,8 +8,6 @@ import (
"runtime"
"sync"
"github.com/rclone/rclone/fs/config"
colorable "github.com/mattn/go-colorable"
)
@@ -70,12 +68,15 @@ const (
var (
// make sure that start is only called once
once sync.Once
// PasswordPromptOutput is output of prompt for password
PasswordPromptOutput = os.Stderr
)
// Start the terminal - must be called before use
func Start() {
once.Do(func() {
f := config.PasswordPromptOutput
f := PasswordPromptOutput
if !IsTerminal(int(f.Fd())) {
// If output is not a tty then remove escape codes
Out = colorable.NewNonColorable(f)