mirror of
https://github.com/go-task/task.git
synced 2025-04-25 12:25:07 +02:00
Add --color=false flag to disable colored output
This commit is contained in:
parent
fb23ba9878
commit
0e575e9c25
@ -60,6 +60,7 @@ func main() {
|
||||
summary bool
|
||||
dir string
|
||||
output string
|
||||
color bool
|
||||
)
|
||||
|
||||
pflag.BoolVar(&versionFlag, "version", false, "show Task version")
|
||||
@ -74,6 +75,7 @@ func main() {
|
||||
pflag.BoolVar(&summary, "summary", false, "show summary about a task")
|
||||
pflag.StringVarP(&dir, "dir", "d", "", "sets directory of execution")
|
||||
pflag.StringVarP(&output, "output", "o", "", "sets output style: [interleaved|group|prefixed]")
|
||||
pflag.BoolVarP(&color, "color", "c", true, "colored output")
|
||||
pflag.Parse()
|
||||
|
||||
if versionFlag {
|
||||
@ -100,6 +102,7 @@ func main() {
|
||||
Dir: dir,
|
||||
Dry: dry,
|
||||
Summary: summary,
|
||||
Color: color,
|
||||
|
||||
Stdin: os.Stdin,
|
||||
Stdout: os.Stdout,
|
||||
|
@ -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...)
|
||||
}
|
||||
|
||||
|
2
task.go
2
task.go
@ -39,6 +39,7 @@ type Executor struct {
|
||||
Silent bool
|
||||
Dry bool
|
||||
Summary bool
|
||||
Color bool
|
||||
|
||||
Stdin io.Reader
|
||||
Stdout io.Writer
|
||||
@ -108,6 +109,7 @@ func (e *Executor) Setup() error {
|
||||
Stdout: e.Stdout,
|
||||
Stderr: e.Stderr,
|
||||
Verbose: e.Verbose,
|
||||
Color: e.Color,
|
||||
}
|
||||
|
||||
v, err := strconv.ParseFloat(e.Taskfile.Version, 64)
|
||||
|
Loading…
x
Reference in New Issue
Block a user