mirror of
https://github.com/go-task/task.git
synced 2025-04-27 12:32:25 +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
|
summary bool
|
||||||
dir string
|
dir string
|
||||||
output string
|
output string
|
||||||
|
color bool
|
||||||
)
|
)
|
||||||
|
|
||||||
pflag.BoolVar(&versionFlag, "version", false, "show Task version")
|
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.BoolVar(&summary, "summary", false, "show summary about a task")
|
||||||
pflag.StringVarP(&dir, "dir", "d", "", "sets directory of execution")
|
pflag.StringVarP(&dir, "dir", "d", "", "sets directory of execution")
|
||||||
pflag.StringVarP(&output, "output", "o", "", "sets output style: [interleaved|group|prefixed]")
|
pflag.StringVarP(&output, "output", "o", "", "sets output style: [interleaved|group|prefixed]")
|
||||||
|
pflag.BoolVarP(&color, "color", "c", true, "colored output")
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
|
|
||||||
if versionFlag {
|
if versionFlag {
|
||||||
@ -100,6 +102,7 @@ func main() {
|
|||||||
Dir: dir,
|
Dir: dir,
|
||||||
Dry: dry,
|
Dry: dry,
|
||||||
Summary: summary,
|
Summary: summary,
|
||||||
|
Color: color,
|
||||||
|
|
||||||
Stdin: os.Stdin,
|
Stdin: os.Stdin,
|
||||||
Stdout: os.Stdout,
|
Stdout: os.Stdout,
|
||||||
|
@ -25,6 +25,7 @@ type Logger struct {
|
|||||||
Stdout io.Writer
|
Stdout io.Writer
|
||||||
Stderr io.Writer
|
Stderr io.Writer
|
||||||
Verbose bool
|
Verbose bool
|
||||||
|
Color bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outf prints stuff to STDOUT.
|
// Outf prints stuff to STDOUT.
|
||||||
@ -32,6 +33,9 @@ func (l *Logger) Outf(print PrintFunc, s string, args ...interface{}) {
|
|||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
s, args = "%s", []interface{}{s}
|
s, args = "%s", []interface{}{s}
|
||||||
}
|
}
|
||||||
|
if !l.Color {
|
||||||
|
print = Default
|
||||||
|
}
|
||||||
print(l.Stdout, s+"\n", args...)
|
print(l.Stdout, s+"\n", args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +51,9 @@ func (l *Logger) Errf(print PrintFunc, s string, args ...interface{}) {
|
|||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
s, args = "%s", []interface{}{s}
|
s, args = "%s", []interface{}{s}
|
||||||
}
|
}
|
||||||
|
if !l.Color {
|
||||||
|
print = Default
|
||||||
|
}
|
||||||
print(l.Stderr, s+"\n", args...)
|
print(l.Stderr, s+"\n", args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
task.go
2
task.go
@ -39,6 +39,7 @@ type Executor struct {
|
|||||||
Silent bool
|
Silent bool
|
||||||
Dry bool
|
Dry bool
|
||||||
Summary bool
|
Summary bool
|
||||||
|
Color bool
|
||||||
|
|
||||||
Stdin io.Reader
|
Stdin io.Reader
|
||||||
Stdout io.Writer
|
Stdout io.Writer
|
||||||
@ -108,6 +109,7 @@ func (e *Executor) Setup() error {
|
|||||||
Stdout: e.Stdout,
|
Stdout: e.Stdout,
|
||||||
Stderr: e.Stderr,
|
Stderr: e.Stderr,
|
||||||
Verbose: e.Verbose,
|
Verbose: e.Verbose,
|
||||||
|
Color: e.Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := strconv.ParseFloat(e.Taskfile.Version, 64)
|
v, err := strconv.ParseFloat(e.Taskfile.Version, 64)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user