Add progress bar configuration and conditional display

This commit introduces a new configuration module `obidefault` to manage progress bar settings, allowing users to disable progress bars via a `--no-progressbar` option. It updates various packages to conditionally display progress bars based on this new configuration, improving user experience by providing control over progress bar output. The changes also include improvements to progress bar handling in several packages, ensuring they are only displayed when appropriate (e.g., when stderr is a terminal and stdout is not piped).
This commit is contained in:
Eric Coissac
2026-02-08 16:13:27 +01:00
parent b2d16721f0
commit 1a28d5ed64
11 changed files with 193 additions and 125 deletions
+2 -3
View File
@@ -31,7 +31,6 @@ var __output_in_json__ = false
var __output_fastjson_format__ = false
var __output_fastobi_format__ = false
var __no_progress_bar__ = false
var __skip_empty__ = false
var __skip_on_error__ = false
@@ -82,7 +81,7 @@ func InputOptionSet(options *getoptions.GetOpt) {
}
func OutputModeOptionSet(options *getoptions.GetOpt, compressed bool) {
options.BoolVar(&__no_progress_bar__, "no-progressbar", false,
options.BoolVar(obidefault.NoProgressBarPtr(), "no-progressbar", obidefault.NoProgressBar(),
options.Description("Disable the progress bar printing"))
if compressed {
@@ -233,7 +232,7 @@ func CLIProgressBar() bool {
oo, _ := os.Stdout.Stat()
toPipe := (oo.Mode() & os.ModeNamedPipe) == os.ModeNamedPipe
return onTerminal && !toPipe && !__no_progress_bar__
return onTerminal && !toPipe && obidefault.ProgressBar()
}
func CLIOutPutFileName() string {
+1 -3
View File
@@ -210,9 +210,7 @@ func CLIReadBioSequences(filenames ...string) (obiiter.IBioSequence, error) {
}
if CLIProgressBar() {
iterator = iterator.Speed("Reading sequences")
}
iterator = iterator.Speed("Reading sequences")
return iterator, nil
}