mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-11-09 17:24:41 +00:00
Disable progress bar when output is piped
Modify CLIProgressBar function to check if stdout is a named pipe and disable the progress bar accordingly. This prevents the progress bar from being displayed when the output is redirected or piped to another command.
This commit is contained in:
1 parent
db98ddb241
commit
7c12b1ee83
1 file changed
+6
-3
@@ -224,13 +224,16 @@ func CLIAnalyzeOnly() int {
|
||||
|
||||
func CLIProgressBar() bool {
|
||||
// If the output is not a terminal, then we do not display the progress bar
|
||||
o, _ := os.Stderr.Stat()
|
||||
onTerminal := (o.Mode() & os.ModeCharDevice) == os.ModeCharDevice
|
||||
oe, _ := os.Stderr.Stat()
|
||||
onTerminal := (oe.Mode() & os.ModeCharDevice) == os.ModeCharDevice
|
||||
if !onTerminal {
|
||||
log.Info("Stderr is redirected, progress bar disabled")
|
||||
}
|
||||
|
||||
return onTerminal && !__no_progress_bar__
|
||||
oo, _ := os.Stdout.Stat()
|
||||
toPipe := (oo.Mode() & os.ModeNamedPipe) == os.ModeNamedPipe
|
||||
|
||||
return onTerminal && !toPipe && !__no_progress_bar__
|
||||
}
|
||||
|
||||
func CLIOutPutFileName() string {
|
||||
|
||||
Reference in new issue
Block a user