File tree Expand file tree Collapse file tree 4 files changed +19
-1
lines changed
Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -17,4 +17,5 @@ require (
1717 github.com/mattn/go-isatty v0.0.20 // indirect
1818 github.com/mattn/go-runewidth v0.0.21 // indirect
1919 golang.org/x/sys v0.42.0 // indirect
20+ golang.org/x/term v0.41.0 // indirect
2021)
Original file line number Diff line number Diff line change @@ -21,3 +21,5 @@ github.com/mattn/go-runewidth v0.0.21/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhg
2121golang.org/x/sys v0.6.0 /go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg =
2222golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo =
2323golang.org/x/sys v0.42.0 /go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw =
24+ golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU =
25+ golang.org/x/term v0.41.0 /go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A =
Original file line number Diff line number Diff line change @@ -89,7 +89,9 @@ func scanDir(dir string) ([]*Duplicates, error) {
8989 })
9090
9191 bar := pb .New64 (total )
92- if flags .Verbose {
92+ // show the bar only when verbose and running on a TTY
93+ showBar := flags .Verbose && isTerminal ()
94+ if showBar {
9395 bar .Set (pb .Bytes , false )
9496 bar .Start ()
9597 }
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "os"
5+
6+ "golang.org/x/term"
7+ )
8+
9+ // isTerminal returns true when stdout is a terminal
10+ func isTerminal () bool {
11+ fd := int (os .Stdout .Fd ())
12+ return term .IsTerminal (fd )
13+ }
You can’t perform that action at this time.
0 commit comments