Repository navigation
cmd/create: Show the spinner only when connected to a terminal - #496
Merged
debarshiray merged 1 commit intoJul 10, 2020
Merged
Conversation
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
force-pushed
the
wip/rishi/spinner-isatty
branch
from
July 9, 2020 17:08
6bf4f1d to
de24292
Compare
|
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
force-pushed
the
wip/rishi/spinner-isatty
branch
from
July 10, 2020 10:05
de24292 to
950f510
Compare
|
Build failed.
|
This was referenced Jul 10, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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