From 48c25e1fe126d45f5c75ea184c3d3ed244194a66 Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Sat, 22 Nov 2025 21:40:52 +0300 Subject: Fixed debug output parts in today subcommand --- src/arts.yaml | 2 +- src/parser.rs | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/arts.yaml b/src/arts.yaml index 6c111e3..585ffd8 100644 --- a/src/arts.yaml +++ b/src/arts.yaml @@ -30,7 +30,7 @@ Arts: {0} \.--.\ //\\ //\\ //\\ /.--./ {0} \\__\\/__\//__\//__\\/__// {0} '--/\\--//\--//\--/\\--' - {0} \\\\///\\//\\\//// + {0} \\\\///\\//\\\o//// {0} ()-= >>\\< <\\> >\\<< =-() {0} ////\\\//\\///\\\\ {0} .--\\/--\//--\//--\//--. diff --git a/src/parser.rs b/src/parser.rs index 6a5166d..8e17682 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -133,7 +133,7 @@ pub fn determine_weather_type(temp: f32, humidity: Option) -> &'static str } /// Arts loader with exception wrappers -fn load_arts() -> Result> { +fn load_arts(debug: bool) -> Result> { let home = std::env::var("HOME")?; let arts_path = format!("{}/.config/WeatherFetch/arts.yaml", home); @@ -151,7 +151,10 @@ fn load_arts() -> Result> { }); } }; - println!("--- RAW FILE CONTENT START ---\n{}\n--- RAW FILE CONTENT END ---", content); + + if debug == true { + println!("--- RAW FILE CONTENT START ---\n{}\n--- RAW FILE CONTENT END ---", content); + } let arts: Arts = serde_yml::from_str(&content)?; Ok(arts.arts) @@ -172,7 +175,7 @@ fn process_placeholders(art: &str) -> String { /// let data: WeatherData = parse_cached()?; /// prepare_art(&data); pub fn prepare_art(weather_data: &WeatherData, debug: bool) -> Result> { - let arts = load_arts()?; + let arts = load_arts(debug)?; let weather_type = determine_weather_type( weather_data.current.temperature_2m, @@ -186,20 +189,20 @@ pub fn prepare_art(weather_data: &WeatherData, debug: bool) -> Result &arts.sun, }; - if(debug == true) { + if debug == true { println!("-- RAW SELECTED ART (debug):\n{:?}\n", selected_art); println!("-- RAW SELECTED ART (display):\n{}\n", selected_art); } let processed_art = process_placeholders(selected_art); - if(debug == true) { - println!("-- PROCESSED ART (debug):\n{:?}\n", processed_art); - println!("-- PROCESSED ART (display):"); - println!("contains ? {}", selected_art.contains("")); - println!("contains ? {}", selected_art.contains("")); - println!("contains ? {}", selected_art.contains("")); - println!("processed contains \\x1b? {}", processed_art.contains("\x1b")); + if debug == true { + println!("-- PROCESSED ART (debug):\n{:?}\n", processed_art); + println!("-- PROCESSED ART (display):"); + println!("contains ? {}", selected_art.contains("")); + println!("contains ? {}", selected_art.contains("")); + println!("contains ? {}", selected_art.contains("")); + println!("processed contains \\x1b? {}", processed_art.contains("\x1b")); } Ok(processed_art) } -- cgit v1.2.3