use std::{thread, time::Duration};
use clx::progress::{ProgressJobBuilder, ProgressStatus};
fn main() {
println!("=== OSC Terminal Progress Demo ===\n");
println!("Starting progress job with OSC integration...");
println!("Watch your terminal's title bar or tab for progress!\n");
let job = ProgressJobBuilder::new()
.body("{{ spinner() }} {{ message }} [{{ cur }}/{{ total }}] {{ progress_bar(flex=true) }}")
.prop("message", "Downloading")
.progress_total(100)
.progress_current(0)
.start();
for i in 0..=100 {
job.progress_current(i);
job.prop("cur", &i);
thread::sleep(Duration::from_millis(30));
}
job.set_status(ProgressStatus::Done);
println!("\nPhase 1 complete!\n");
thread::sleep(Duration::from_millis(500));
println!("Demonstrating status-based OSC states...\n");
let job2 = ProgressJobBuilder::new()
.prop("message", "Processing files")
.progress_total(50)
.progress_current(0)
.start();
for i in 0..=25 {
job2.progress_current(i);
thread::sleep(Duration::from_millis(50));
}
println!("Simulating error state...");
job2.set_status(ProgressStatus::Failed);
thread::sleep(Duration::from_secs(1));
let job3 = ProgressJobBuilder::new()
.prop("message", "Retrying")
.progress_total(50)
.progress_current(0)
.start();
for i in 0..=50 {
job3.progress_current(i);
thread::sleep(Duration::from_millis(30));
}
job3.set_status(ProgressStatus::Done);
println!("\n=== Demo Complete ===");
println!("The OSC progress indicator should now be cleared.");
thread::sleep(Duration::from_millis(100));
}