progress/
progress.rs

1use hackerlog::*;
2use std::thread;
3use std::time::Duration;
4
5fn main() {
6    // Basic progress without total
7    let mut progress = Progress::new("Processing");
8    for _ in 0..5 {
9        thread::sleep(Duration::from_millis(300));
10        progress.inc(1);
11    }
12    progress.finish();
13
14    // Progress with total
15    let mut progress = Progress::with_total("Downloading", 100);
16    for i in 0..=10 {
17        thread::sleep(Duration::from_millis(100));
18        progress.inc(10);
19        progress.update(format!("Downloading chunk {}/10", i));
20    }
21    progress.finish_with_message("Download complete!");
22
23    // Multiple progress indicators
24    let mut scan = Progress::with_total("Port scan", 1000);
25    let mut analysis = Progress::new("Analyzing results");
26
27    for i in (0..=1000).step_by(100) {
28        thread::sleep(Duration::from_millis(50));
29        scan.inc(100);
30        if i % 200 == 0 {
31            analysis.inc(1);
32        }
33    }
34
35    scan.finish();
36    analysis.finish_with_message("Analysis complete - Found 5 open ports");
37}