cli icon indicating copy to clipboard operation
cli copied to clipboard

Update message is printed to stdout instead of stderr

Open JakeChampion opened this issue 1 year ago • 3 comments

Version

Fastly CLI version v4.1.0 (b4884e4) Built with go version go1.18.6 linux/amd64 Viceroy version: viceroy 0.2.15

What happened

When a newer version of the fastly cli is available, the cli prints an update message to stdout, which can cause issues for scripts that were expecting stdout to contain only the expected output of the command that was run.

E.G. fastly profile token will usually just print the token, but when a newer cli version if available, it will also print the update message to stdout.

Could we update the fastly cli to print the update message to stderr instead of stdout? https://github.com/fastly/cli/blob/e6d4c7946af24d0ec3f87d808c7ac39f64e32e4e/pkg/app/run.go#L189

JakeChampion avatar Oct 12 '22 14:10 JakeChampion

My only concern with printing to os.Stderr is that this message isn't an error and is genuinely intended for stdout.

So I'm thinking instead this output should be wrapped in a condition such that it only prints if --verbose is set.

Integralist avatar Oct 12 '22 14:10 Integralist

The downside of that is that people almost never use --verbose, but the alternative isn't as nice and would mean adding a --quiet flag instead so a user would have to explicitly opt into using it for a command like profile token.

Integralist avatar Oct 12 '22 14:10 Integralist

I'm all for a --quiet flag 👍

JakeChampion avatar Oct 12 '22 14:10 JakeChampion