mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-03-25 13:30:52 +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:
@@ -224,13 +224,16 @@ func CLIAnalyzeOnly() int {
|
|||||||
|
|
||||||
func CLIProgressBar() bool {
|
func CLIProgressBar() bool {
|
||||||
// If the output is not a terminal, then we do not display the progress bar
|
// If the output is not a terminal, then we do not display the progress bar
|
||||||
o, _ := os.Stderr.Stat()
|
oe, _ := os.Stderr.Stat()
|
||||||
onTerminal := (o.Mode() & os.ModeCharDevice) == os.ModeCharDevice
|
onTerminal := (oe.Mode() & os.ModeCharDevice) == os.ModeCharDevice
|
||||||
if !onTerminal {
|
if !onTerminal {
|
||||||
log.Info("Stderr is redirected, progress bar disabled")
|
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 {
|
func CLIOutPutFileName() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user