From 3077c3c5331e211dbc8572036c98d9d5f14a7d98 Mon Sep 17 00:00:00 2001 From: sudarsan1030 Date: Fri, 26 Jun 2026 10:21:45 +0530 Subject: [PATCH 1/2] implemented new changes --- src/env_validator.rs | 25 +++++++++++++++++++++++++ src/main.rs | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/env_validator.rs b/src/env_validator.rs index d31c71c..6d21e56 100644 --- a/src/env_validator.rs +++ b/src/env_validator.rs @@ -1,5 +1,8 @@ use regex::Regex; use std::collections::HashSet; +use std::collections::HashMap; +use std::fs; +use std::io; pub fn extract_env_variables(source: &str) -> Vec { @@ -29,4 +32,26 @@ pub fn extract_env_variables(source: &str) -> Vec { let mut result: Vec = vars.into_iter().collect(); result.sort(); result +} + +pub fn parse_env_file(path: &str) -> io::Result> { + let content = fs::read_to_string(path)?; + let mut vars = HashMap::new(); + + for line in content.lines() { + let line = line.trim(); + + if line.is_empty() || line.starts_with('#') { + continue; + } + + if let Some((key, value)) = line.split_once('=') { + vars.insert( + key.trim().to_string(), + value.trim().to_string(), + ); + } + } + + Ok(vars) } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f52a3f9..e0d1e7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ mod env_validator; fn main() { - println!("issue 4!!!"); + println!("issue 5 solution"); } \ No newline at end of file From 91c23dc385a452d76d60fd6873ea6e16428cb8a4 Mon Sep 17 00:00:00 2001 From: sudarsan1030 Date: Fri, 26 Jun 2026 15:40:26 +0530 Subject: [PATCH 2/2] implemented env engine --- src/env_validator.rs | 29 +++++++++++++++++++++++++++++ src/main.rs | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/env_validator.rs b/src/env_validator.rs index 6d21e56..656ee86 100644 --- a/src/env_validator.rs +++ b/src/env_validator.rs @@ -5,6 +5,7 @@ use std::fs; use std::io; + pub fn extract_env_variables(source: &str) -> Vec { let mut vars = HashSet::new(); @@ -54,4 +55,32 @@ pub fn parse_env_file(path: &str) -> io::Result> { } Ok(vars) +} + +pub fn validate_env( + extracted: &[String], + env: &HashMap, +) { + println!("Validation Report"); + + println!("\nMissing Variables:"); + for var in extracted { + if !env.contains_key(var) { + println!("- {}", var); + } + } + + println!("\nUnused Variables:"); + for key in env.keys() { + if !extracted.contains(key) { + println!("- {}", key); + } + } + + println!("\nEmpty Variables:"); + for (key, value) in env { + if value.trim().is_empty() { + println!("- {}", key); + } + } } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e0d1e7c..224d42e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ mod env_validator; fn main() { - println!("issue 5 solution"); + println!("issue 4/5/6 solution"); } \ No newline at end of file