cloudfoundry/cli — pull request #136 by julz (2014-04-04 18:11:08+00:00)
Title: Disable CF_COLOR when not in a tty (using go.crypto package)

Following on from the [gcf and colours discussion] (https://groups.google.com/a/cloudfoundry.org/forum/#!msg/vcap-dev/3rwzl8RQnWU/kQ_-PR4DlO8J) in vcap-dev.

As @nebhale says in the above discussion, "Many other command line interfaces that have color notice when they are being run via script versus in a tty and act accordingly. This is why tools like Git can produce colors, but their output can also be used when scripting without having to set a special flag. It'd be nice if gcf would do the same.". This makes gcf do the same.

This only changes what happens when CF_COLOR is not specified. CF_COLOR=true continues to be the effective default on non-windows systems when running in a tty. But when NOT in a tty, after this change CF_COLOR effectively defaults to false (but you can still explicitly enable colours in this case by setting it to true, rather than leaving it empty). CF_COLOR=false (still) always disables, CF_COLOR=true (still) always enables (unless you're on windows). Not specifying CF_COLOR (or setting it empty) does something intelligent based on whether stdout is a terminal.

------

**Note:** This is an alternative implementation of https://github.com/cloudfoundry/cli/pull/135. This version uses the go.crypto library. Go.crypto is a submodule of the go repo, but it's a mercurial repo so I couldn't find a way to include it as a submodule of this repo. So I had to import the full source in this PR. Would be very interested to know about any way of including it without doing this. Note the go.net package is imported in a similar way already in `src/code.google.com/p/go.net`.