2026-02-08 16:13:27 +01:00
|
|
|
package obidefault
|
|
|
|
|
|
2026-11-02 22:33:00 +11:00
|
|
|
import "os"
|
|
|
|
|
|
2026-02-08 16:13:27 +01:00
|
|
|
var __no_progress_bar__ = false
|
|
|
|
|
|
|
|
|
|
func ProgressBar() bool {
|
|
|
|
|
return !__no_progress_bar__
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NoProgressBar() bool {
|
|
|
|
|
return __no_progress_bar__
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func SetNoProgressBar(b bool) {
|
|
|
|
|
__no_progress_bar__ = b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NoProgressBarPtr() *bool {
|
|
|
|
|
return &__no_progress_bar__
|
|
|
|
|
}
|
2026-11-02 22:33:00 +11:00
|
|
|
|
|
|
|
|
// ProgressBarVisible tells whether a progress bar can be displayed: it is not
|
|
|
|
|
// disabled by --no-progressbar, the standard error output is a terminal and
|
|
|
|
|
// the standard output is not piped to another command.
|
|
|
|
|
func ProgressBarVisible() bool {
|
|
|
|
|
if !ProgressBar() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if e, err := os.Stderr.Stat(); err != nil || (e.Mode()&os.ModeCharDevice) != os.ModeCharDevice {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if o, err := os.Stdout.Stat(); err == nil && (o.Mode()&os.ModeNamedPipe) == os.ModeNamedPipe {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
}
|