mirror of
https://github.com/rclone/rclone.git
synced 2025-01-13 20:38:12 +02:00
bisync: fix --colors flag
quick fix to get around lack of support in fs.Infof etc.
This commit is contained in:
parent
0f549520ef
commit
8d3bcc025a
@ -189,8 +189,6 @@ type bisyncTest struct {
|
|||||||
TestFn bisync.TestFunc
|
TestFn bisync.TestFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
const TerminalColorMode = fs.TerminalColorModeAlways
|
|
||||||
|
|
||||||
var color = bisync.Color
|
var color = bisync.Color
|
||||||
|
|
||||||
// TestBisync is a test engine for bisync test cases.
|
// TestBisync is a test engine for bisync test cases.
|
||||||
@ -206,6 +204,7 @@ func TestBisync(t *testing.T) {
|
|||||||
if *argRefreshTimes {
|
if *argRefreshTimes {
|
||||||
ci.RefreshTimes = true
|
ci.RefreshTimes = true
|
||||||
}
|
}
|
||||||
|
bisync.Colors = true
|
||||||
|
|
||||||
baseDir, err := os.Getwd()
|
baseDir, err := os.Getwd()
|
||||||
require.NoError(t, err, "get current directory")
|
require.NoError(t, err, "get current directory")
|
||||||
|
@ -62,8 +62,13 @@ func quotePath(path string) string {
|
|||||||
return escapePath(path, true)
|
return escapePath(path, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Colors bool // Colors controls whether terminal colors are enabled
|
||||||
|
|
||||||
// Color handles terminal colors for bisync
|
// Color handles terminal colors for bisync
|
||||||
func Color(style string, s string) string {
|
func Color(style string, s string) string {
|
||||||
|
if !Colors {
|
||||||
|
return s
|
||||||
|
}
|
||||||
terminal.Start()
|
terminal.Start()
|
||||||
return style + s + terminal.Reset
|
return style + s + terminal.Reset
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/rclone/rclone/cmd/bisync/bilib"
|
"github.com/rclone/rclone/cmd/bisync/bilib"
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
"github.com/rclone/rclone/fs/accounting"
|
"github.com/rclone/rclone/fs/accounting"
|
||||||
|
"github.com/rclone/rclone/fs/log"
|
||||||
"github.com/rclone/rclone/fs/operations"
|
"github.com/rclone/rclone/fs/operations"
|
||||||
"github.com/rclone/rclone/lib/atexit"
|
"github.com/rclone/rclone/lib/atexit"
|
||||||
"github.com/rclone/rclone/lib/terminal"
|
"github.com/rclone/rclone/lib/terminal"
|
||||||
@ -80,6 +81,10 @@ func Bisync(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options) (err error) {
|
|||||||
ci := fs.GetConfig(ctx)
|
ci := fs.GetConfig(ctx)
|
||||||
opt.OrigBackupDir = ci.BackupDir
|
opt.OrigBackupDir = ci.BackupDir
|
||||||
|
|
||||||
|
if ci.TerminalColorMode == fs.TerminalColorModeAlways || (ci.TerminalColorMode == fs.TerminalColorModeAuto && !log.Redirected()) {
|
||||||
|
Colors = true
|
||||||
|
}
|
||||||
|
|
||||||
err = b.setCompareDefaults(ctx)
|
err = b.setCompareDefaults(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user