vivo/
ui.rs

1use colored::*;
2use term_size;
3
4pub fn section_header(message: &str) {
5    // Define the base number of dashes and max line length
6    let prefix_dashes = "----"; // Start with 4 dashes
7    let max_line_length = 70; // Maximum allowed line length
8
9    // Get terminal width or use 50 as a fallback
10    let term_width = term_size::dimensions()
11        .map(|(w, _)| w)
12        .unwrap_or(max_line_length);
13    let line_length = term_width.min(max_line_length); // Don't exceed 70 chars
14
15    // Calculate the number of dashes needed to fill the remaining space
16    let message_len = message.len();
17    let dashes_needed = line_length.saturating_sub(prefix_dashes.len() + message_len + 10); // +10 for " Running task [] "
18
19    let task_message = format!(
20        "{} {} {}",
21        prefix_dashes.blue(),
22        message.green(),
23        "-".repeat(dashes_needed).blue()
24    );
25
26    println!();
27    println!("{}", task_message);
28}
29
30pub fn info(message: &str) {
31    println!("[{}] {}", "i".blue(), message);
32}