pub fn create_progress_bar(total: u64) -> ProgressBarExpand description
Create a progress bar with consistent styling and configuration.
Creates a progress bar with customized styling that respects user
configuration preferences. The progress bar can be hidden based on
the enable_progress_bar configuration setting, allowing users to
disable progress indicators if desired.
§Configuration Integration
The progress bar visibility is controlled by the configuration setting:
[general]
enable_progress_bar = true # Show progress bars
# or
enable_progress_bar = false # Hide progress bars§Progress Bar Features
- Animated spinner: Indicates ongoing activity
- Elapsed time: Shows time since operation started
- Progress bar: Visual representation of completion percentage
- ETA estimation: Estimated time to completion
- Current/total counts: Numeric progress indicator
§Template Format
⠋ [00:01:23] [████████████████████████████████████████] 75/100 (00:00:17) movie.srt§Arguments
total- The total number of items to be processed
§Returns
A configured ProgressBar instance ready for use
§Examples
use subx_cli::cli::ui::create_progress_bar;
// Create progress bar for 100 items
let progress = create_progress_bar(100);
for i in 0..100 {
// ... process item ...
progress.inc(1);
if i % 10 == 0 {
progress.set_message(format!("Processing item {}", i));
}
}
progress.finish_with_message("✓ All items processed successfully");§Error Handling
If configuration loading fails, the progress bar will default to visible. This ensures that progress indication is available even when configuration is problematic.
§Style contract
The shared template is
{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta}) {msg}:
the trailing {msg} segment lets a caller-set message — the parallel
batch’s Active: … | Queued: … | Completed: … line or any bar message —
render; a bar whose caller never sets a message renders it empty.
This is the CLI’s only ProgressBar constructor; batch progress bars are
constructed by the reporter in cli::reporter on ProgressEvent::Started.