Skip to content

cmd/create: Show the spinner only when connected to a terminal - #496

Merged
debarshiray merged 1 commit into
containers:masterfrom
debarshiray:wip/rishi/spinner-isatty
Jul 10, 2020
Merged

debarshiray merged 1 commit into
containers:masterfrom
debarshiray:wip/rishi/spinner-isatty

Conversation

@debarshiray

Copy link
Copy Markdown
Member

It doesn't make sense to show a spinner when the output is redirected
to something other than a terminal.

The spinner package we're using [0] has a problem with printing
additional characters when it's output (the standard output, in this
case) is not connected to a terminal.

This causes problems in our test suite (corrupts the output that is
checked). To prevent this the spinner should only be started when the
output of the program is not piped.

This uses the golang.org/x/crypto/ssh/terminal package to check if the
standard output is connected to a terminal or not, which is also what
Podman uses. The other option was the github.com/mattn/go-isatty
package but using it leads to a slightly bigger binary - 7778323 bytes
versus 7782284.

[0] https://github.com/briandowns/spinner

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jul 9, 2020
It doesn't make sense to show a spinner when the output is redirected
to something other than a terminal.

The spinner package we're using [0] has a problem with printing
additional characters when it's output (the standard output, in this
case) is not connected to a terminal.

This causes problems in our test suite (corrupts the output that is
checked). To prevent this the spinner should only be started when the
output of the program is not piped.

This uses the golang.org/x/crypto/ssh/terminal package to check if the
standard output is connected to a terminal or not, which is also what
Podman uses. The other option was the github.com/mattn/go-isatty
package but using it leads to a slightly bigger binary - 7778323 bytes
versus 7782284.

[0] https://github.com/briandowns/spinner

containers#496
@debarshiray
debarshiray force-pushed the wip/rishi/spinner-isatty branch from 6bf4f1d to de24292 Compare July 9, 2020 17:08
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

It doesn't make sense to show a spinner when the output is redirected
to something other than a terminal. When the output is not connected
to a terminal, the terminal escape sequences and other control
characters used to render the spinner leads to some spurious
characters in the output, which confuses the test suite.

This uses the golang.org/x/crypto/ssh/terminal package to check if the
standard output is connected to a terminal or not, which is also what
Podman uses. The other option was the github.com/mattn/go-isatty
package but using it leads to a slightly bigger binary - 7778323 bytes
versus 7782284.

[0] https://github.com/briandowns/spinner

containers#496
@debarshiray
debarshiray force-pushed the wip/rishi/spinner-isatty branch from de24292 to 950f510 Compare July 10, 2020 10:05
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@debarshiray
debarshiray merged commit 950f510 into containers:master Jul 10, 2020
@debarshiray
debarshiray deleted the wip/rishi/spinner-isatty branch July 10, 2020 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants