1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

Add --color=false flag to disable colored output

This commit is contained in:
Andrey Nering
2019-07-07 14:13:53 -03:00
parent fb23ba9878
commit 0e575e9c25
3 changed files with 12 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ type Logger struct {
Stdout io.Writer
Stderr io.Writer
Verbose bool
Color bool
}
// Outf prints stuff to STDOUT.
@@ -32,6 +33,9 @@ func (l *Logger) Outf(print PrintFunc, s string, args ...interface{}) {
if len(args) == 0 {
s, args = "%s", []interface{}{s}
}
if !l.Color {
print = Default
}
print(l.Stdout, s+"\n", args...)
}
@@ -47,6 +51,9 @@ func (l *Logger) Errf(print PrintFunc, s string, args ...interface{}) {
if len(args) == 0 {
s, args = "%s", []interface{}{s}
}
if !l.Color {
print = Default
}
print(l.Stderr, s+"\n", args...)
}