chelnak / ysmrr

YSMRR is a package that provides simple multi-line compatible spinners for Go applications.
MIT License
71 stars 6 forks source link

Improve TTY detection #30

Closed chelnak closed 1 year ago

chelnak commented 1 year ago

Prior to this PR there was no TTY detection in the manager or tput package. The result was that during non-interactive executions escape sequences would also be written to the output stream. Additionally each frame would also be written.

For example, running the following would result in a messy log file:

go run examples/advanced/main.go |& tee log.log

This introduces changes that do the following:

It is also possible to override the above by setting the environment variable YSMRR_FORCE_TTY to true. This will make ysmrr ignore tty detection and render frames and write escape sequences.

An example of the above override can be seen in the tput_test.go file.