progress_basic/
progress_basic.rs1use std::{thread, time::Duration};
2
3use xacli_components::ProgressBar;
4
5fn main() {
6 println!("=== ProgressBar Component Demo ===\n");
7
8 let (bar, handle) = ProgressBar::new(100, "Downloading...");
9
10 let task = thread::spawn(move || {
12 for i in 0..100 {
13 thread::sleep(Duration::from_millis(50));
14 handle.inc(1);
15
16 if i == 50 {
18 handle.set_message("Processing...");
19 }
20 }
21 handle.finish();
22 });
23
24 if let Err(e) = bar.run() {
26 eprintln!("Error: {}", e);
27 }
28
29 task.join().unwrap();
31
32 println!("Done!");
33}