mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 03:50:39 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user