From 212e2526fcc3775e23e2c362d8d13cac4374b534 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 13 Feb 2026 14:52:13 +0100 Subject: [PATCH] build(cargo): adding the utils automod --- build.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build.rs b/build.rs index 676bed4..0a51531 100644 --- a/build.rs +++ b/build.rs @@ -9,6 +9,7 @@ const COMMAND_DIR: &str = "./src/commands/"; const EVENT_DIR: &str = "./src/events/"; const MODEL_DIR: &str = "./src/models/"; const DB_DIR: &str = "./src/database/"; +const UTILS_DIR: &str = "./src/database/"; const MOD_PREFIX: &str = "pub mod "; const MOD_FILE: &str = "/mod_gen.rs"; @@ -132,6 +133,20 @@ fn database_helper() -> io::Result<()> { Ok(()) } +fn utils() -> io::Result<()> { + let root: &Path = Path::new(UTILS_DIR); + let sources: Vec = read_dir(root); + let mut modules: String = String::new(); + println!("'utils'"); + for source in sources { + modules = modules + &String::from(MOD_PREFIX) + &source + &String::from(";\n"); + println!("\t'{}'", source); + } + write(String::from(UTILS_DIR) + &String::from(MOD_FILE), modules)?; + + Ok(()) +} + fn main() { if let Err(e) = commands() { panic!("Error when writing the commands \n{}", e) @@ -145,4 +160,7 @@ fn main() { if let Err(e) = database_helper() { panic!("Error when writing the database_helper:\n{}", e) } + if let Err(e) = utils() { + panic!("Error when writing the database_helper:\n{}", e) + } }