feat: Migrate SAL to Cargo workspace
Some checks failed
Rhai Tests / Run Rhai Tests (push) Has been cancelled
Rhai Tests / Run Rhai Tests (pull_request) Has been cancelled

- Migrate individual modules to independent crates
- Refactor dependencies for improved modularity
- Update build system and testing infrastructure
- Update documentation to reflect new structure
This commit is contained in:
Mahmoud-Emad
2025-06-24 12:39:18 +03:00
parent 8012a66250
commit e125bb6511
54 changed files with 1196 additions and 1582 deletions

View File

@@ -49,32 +49,34 @@ pub fn run(script_path: &str) -> Result<(), Box<dyn Error>> {
// Directory - collect all .rhai files recursively and sort them
let mut files = Vec::new();
collect_rhai_files(path, &mut files)?;
if files.is_empty() {
eprintln!("No .rhai files found in directory: {}", script_path);
process::exit(1);
}
// Sort files for consistent execution order
files.sort();
files
} else {
eprintln!("Error: '{}' is neither a file nor a directory", script_path);
process::exit(1);
};
println!("Found {} Rhai script{} to execute:",
script_files.len(),
if script_files.len() == 1 { "" } else { "s" });
println!(
"Found {} Rhai script{} to execute:",
script_files.len(),
if script_files.len() == 1 { "" } else { "s" }
);
// Execute each script in sorted order
for script_file in script_files {
println!("\nExecuting: {}", script_file.display());
// Read the script content
let script = fs::read_to_string(&script_file)?;
// Execute the script
match engine.eval::<rhai::Dynamic>(&script) {
Ok(result) => {
@@ -82,7 +84,7 @@ pub fn run(script_path: &str) -> Result<(), Box<dyn Error>> {
if !result.is_unit() {
println!("Result: {}", result);
}
},
}
Err(err) => {
eprintln!("Error executing script: {}", err);
// Exit with error code when a script fails
@@ -109,7 +111,7 @@ fn collect_rhai_files(dir: &Path, files: &mut Vec<PathBuf>) -> Result<(), Box<dy
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if path.is_dir() {
// Recursively search subdirectories
collect_rhai_files(&path, files)?;
@@ -122,6 +124,6 @@ fn collect_rhai_files(dir: &Path, files: &mut Vec<PathBuf>) -> Result<(), Box<dy
}
}
}
Ok(())
}