From fc82aab74b9f0187d38fb01890af287b0c0f6cc7 Mon Sep 17 00:00:00 2001 From: Richard Guan Date: Mon, 16 Jan 2023 16:14:19 +1100 Subject: [PATCH] add bool flag and gen documentation --- cmd/lotus/main.go | 11 +++++++++++ documentation/en/cli-lotus.md | 1 + 2 files changed, 12 insertions(+) diff --git a/cmd/lotus/main.go b/cmd/lotus/main.go index c19b9fce4..85324e466 100644 --- a/cmd/lotus/main.go +++ b/cmd/lotus/main.go @@ -4,6 +4,7 @@ import ( "context" "os" + "github.com/fatih/color" logging "github.com/ipfs/go-log/v2" "github.com/mattn/go-isatty" "github.com/urfave/cli/v2" @@ -52,6 +53,10 @@ func main() { } jaeger = tracing.SetupJaegerTracing("lotus/" + cmd.Name) + if cctx.IsSet("color") { + color.NoColor = !cctx.Bool("color") + } + if originBefore != nil { return originBefore(cctx) } @@ -75,6 +80,12 @@ func main() { Hidden: true, Value: "~/.lotus", // should follow --repo default }, + &cli.BoolFlag{ + // examined in the Before above + Name: "color", + Usage: "use color in display output", + DefaultText: "depends on output being a TTY", + }, &cli.StringFlag{ Name: "repo", EnvVars: []string{"LOTUS_PATH"}, diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index 86ce59ba4..53f55e61d 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -38,6 +38,7 @@ COMMANDS: status Check node status GLOBAL OPTIONS: + --color use color in display output (default: depends on output being a TTY) --force-send if true, will ignore pre-send checks (default: false) --help, -h show help (default: false) --interactive setting to false will disable interactive functionality of commands (default: false)