Enable color by default only if os.Stdout is a TTY

This commit is contained in:
Peter Rabbitson
2021-07-07 18:12:24 +02:00
parent 49896afe9f
commit c7bb326c78
9 changed files with 39 additions and 12 deletions
+4 -3
View File
@@ -45,6 +45,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/types"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/lib/tablewriter"
)
@@ -1233,7 +1234,7 @@ var clientListRetrievalsCmd = &cli.Command{
&cli.BoolFlag{
Name: "color",
Usage: "use color in display output",
Value: true,
Value: cliutil.DefaultColorUse,
},
&cli.BoolFlag{
Name: "show-failed",
@@ -1806,7 +1807,7 @@ var clientListDeals = &cli.Command{
&cli.BoolFlag{
Name: "color",
Usage: "use color in display output",
Value: true,
Value: cliutil.DefaultColorUse,
},
&cli.BoolFlag{
Name: "show-failed",
@@ -2336,7 +2337,7 @@ var clientListTransfers = &cli.Command{
&cli.BoolFlag{
Name: "color",
Usage: "use color in display output",
Value: true,
Value: cliutil.DefaultColorUse,
},
&cli.BoolFlag{
Name: "completed",
+9
View File
@@ -0,0 +1,9 @@
package cliutil
import (
"os"
"github.com/mattn/go-isatty"
)
var DefaultColorUse = isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())