# HG changeset patch # User Mikael Berthe # Date 1494438489 -7200 # Node ID 590c9dd7328e607fe341d235a7c3488c76245df2 # Parent 2e411da68fd3bb9220bf4ed939d7fe826aa02fce Improve config dump output Do not display instructions when stdout is not a TTY. diff -r 2e411da68fd3 -r 590c9dd7328e cmd/config.go --- a/cmd/config.go Wed May 10 14:11:13 2017 +0200 +++ b/cmd/config.go Wed May 10 19:48:09 2017 +0200 @@ -8,6 +8,7 @@ import ( "os" + "github.com/mattn/go-isatty" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -89,9 +90,11 @@ if cfile == "" { cfile = defaultConfigFile } - errPrint("You can copy the following lines into a configuration file.") - errPrint("E.g. %s -i INSTANCE -L USERNAME -P PASS config dump > %s", AppName, cfile) - errPrint(" or %s -i INSTANCE oauth2 > %s\n", AppName, cfile) + if isatty.IsTerminal(os.Stdout.Fd()) { + errPrint("You can copy the following lines into a configuration file.") + errPrint("E.g. %s -i INSTANCE -L USERNAME -P PASS config dump > %s", AppName, cfile) + errPrint(" or %s -i INSTANCE oauth2 > %s\n", AppName, cfile) + } pOptions := printer.Options{"template": configurationTemplate} p, err = printer.NewPrinterTemplate(pOptions) } else {