mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
fs: Add global flag '--color' to control terminal colors
* fs: add TerminalColorMode type * fs: add new config(flags) for TerminalColorMode * lib/terminal: use TerminalColorMode to determine how to handle colors * Add documentation for '--terminal-color-mode' * tree: remove obsolete --color replaced by global --color This changes the default behaviour of tree. It now displays colors by default instead of only displaying them when the flag -C/--color was active. Old behaviour (no color) can be achieved by setting --color to 'never'. Fixes: #6604
This commit is contained in:
@@ -61,7 +61,6 @@ func init() {
|
||||
flags.StringVarP(cmdFlags, &sort, "sort", "", "", "Select sort: name,version,size,mtime,ctime")
|
||||
// Graphics
|
||||
flags.BoolVarP(cmdFlags, &opts.NoIndent, "noindent", "", false, "Don't print indentation lines")
|
||||
flags.BoolVarP(cmdFlags, &opts.Colorize, "color", "C", false, "Turn colorization on always")
|
||||
}
|
||||
|
||||
var commandDefinition = &cobra.Command{
|
||||
@@ -116,6 +115,7 @@ For a more interactive navigation of the remote see the
|
||||
opts.SizeSort = sort == "size"
|
||||
ci := fs.GetConfig(context.Background())
|
||||
opts.UnitSize = ci.HumanReadable
|
||||
opts.Colorize = ci.TerminalColorMode != fs.TerminalColorModeNever
|
||||
if opts.DeepLevel == 0 {
|
||||
opts.DeepLevel = ci.MaxDepth
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user