From eeae39d050f22edcae63ac8b3afa797dab8955b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sun, 16 Feb 2025 21:37:03 +0100 Subject: [PATCH] Don't duplicate current session print --- src/commands.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index eefc0c8..e8a581a 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -212,7 +212,7 @@ fn format_bar(seconds: i64, max_value: i64, width: usize) -> String { let ratio = (seconds as f64) / (max_value as f64); let full_blocks = (ratio * (width as f64)) as usize; let remainder = ((ratio * (width as f64) - full_blocks as f64) * 8.0) as usize; - + let mut bar = String::new(); for _ in 0..full_blocks { bar.push_str(BLOCKS[7]); @@ -276,7 +276,7 @@ pub async fn status(settings: Settings) -> Result<(), CliError> { let duration = now.naive_local().signed_duration_since(active_period.start_time); let duration_str = format_duration(duration.num_seconds()); println!("\n{}", "Current Session".bold()); - println!("Active for: {} (started at {})", + println!("Active for: {} (started at {})", duration_str.yellow(), active_period.start_time.format("%H:%M").to_string().yellow() ); @@ -299,12 +299,6 @@ pub async fn status(settings: Settings) -> Result<(), CliError> { const BOX_WIDTH: usize = 50; const BAR_WIDTH: usize = 20; - - // Print active session if exists - if status.active != "0" && status.active != "" { - println!("\n{}", "Current Session".bold()); - println!("Active for: {}", status.active.yellow()); - } // Print weekly overview with visual bars println!("\n{}", "Weekly Work Overview".bold()); @@ -315,19 +309,19 @@ pub async fn status(settings: Settings) -> Result<(), CliError> { let date = week_start_date + chrono::Duration::days(i); let seconds = daily.get(&date).cloned().unwrap_or(0); total += seconds; - + let day = date.format("%a").to_string().bold(); let duration = format_duration(seconds); // Ensure the day and duration part is exactly 15 characters wide let day_str = format!("{:<3} {:<10}", day, duration); - - println!("{:<15} {: Result<(), CliError> { println!("\n{}", "Extended Statistics".bold()); println!("This Month: {}", status.month.cyan()); println!("This Year: {}", status.year.cyan()); - + Ok(()) } @@ -350,4 +344,4 @@ fn format_duration(seconds: i64) -> String { let hours = seconds / 3600; let minutes = (seconds % 3600) / 60; format!("{}h {}m", hours, minutes) -} \ No newline at end of file +}