Print a step indicator like "[2/5] Doing something..." without advancing to the next line, so it can be updated in-place by a subsequent call to [`print_step_done`].
(step: usize, total: usize, msg: &str)
| 87 | /// Print a step indicator like "[2/5] Doing something..." without advancing to the next line, |
| 88 | /// so it can be updated in-place by a subsequent call to [`print_step_done`]. |
| 89 | pub fn print_step(step: usize, total: usize, msg: &str) { |
| 90 | let prefix = theme_style().apply_to(format!("[{step}/{total}]")); |
| 91 | // Clear the current line and print without newline |
| 92 | print!("\r\x1b[2K{prefix} {msg}"); |
| 93 | let _ = std::io::stdout().flush(); |
| 94 | } |
| 95 | |
| 96 | /// Print a step completion message like "[2/5] Done ✓", overwriting the previous step |
| 97 | /// indicator printed by [`print_step`] in-place, and then move to the next line. |