pub struct ProgressBar { /* private fields */ }Expand description
Progress bar for determinate operations with known total.
Automatically suppressed in non-TTY, JSON mode, or quiet mode. When suppressed, all operations become no-ops.
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.set_message("Processing...");
for i in 0..100 {
pb.inc(1);
}
pb.finish_with_message("✓ Done");Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub fn new(len: u64) -> Self
pub fn new(len: u64) -> Self
Creates a new progress bar with the given length.
The progress bar is automatically suppressed if:
- stdout is not a TTY
- Output format is JSON or quiet
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);Sourcepub fn new_with_format(len: u64, format: OutputFormat) -> Self
pub fn new_with_format(len: u64, format: OutputFormat) -> Self
Creates a new progress bar with explicit format control.
§Examples
use sublime_cli_tools::output::{progress::ProgressBar, OutputFormat};
let pb = ProgressBar::new_with_format(100, OutputFormat::Human);Sourcepub fn set_message(&self, msg: impl Into<String>)
pub fn set_message(&self, msg: impl Into<String>)
Sets the progress bar message.
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.set_message("Downloading files...");Sourcepub fn set_position(&self, pos: u64)
pub fn set_position(&self, pos: u64)
Sets the current position of the progress bar.
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.set_position(50);Sourcepub fn inc(&self, delta: u64)
pub fn inc(&self, delta: u64)
Increments the progress bar by the given amount.
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.inc(1);Sourcepub fn set_length(&self, len: u64)
pub fn set_length(&self, len: u64)
Sets the progress bar length.
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.set_length(200);Sourcepub fn finish(&self)
pub fn finish(&self)
Finishes the progress bar and clears it.
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.finish();Sourcepub fn finish_with_message(&self, msg: impl Into<String>)
pub fn finish_with_message(&self, msg: impl Into<String>)
Finishes the progress bar with a message.
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.finish_with_message("✓ Complete");Sourcepub fn abandon(&self)
pub fn abandon(&self)
Finishes the progress bar and abandons it (shows as incomplete).
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.abandon();Sourcepub fn abandon_with_message(&self, msg: impl Into<String>)
pub fn abandon_with_message(&self, msg: impl Into<String>)
Finishes the progress bar and abandons it with a message.
§Examples
use sublime_cli_tools::output::progress::ProgressBar;
let pb = ProgressBar::new(100);
pb.abandon_with_message("✗ Failed");Auto Trait Implementations§
impl Freeze for ProgressBar
impl RefUnwindSafe for ProgressBar
impl Send for ProgressBar
impl Sync for ProgressBar
impl Unpin for ProgressBar
impl UnwindSafe for ProgressBar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more