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

@@ -81,7 +81,7 @@ impl Error for DownloadError {
* # Examples
*
* ```no_run
* use sal::os::download;
* use sal_os::download;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Download a file with no minimum size requirement
@@ -242,7 +242,7 @@ pub fn download(url: &str, dest: &str, min_size_kb: i64) -> Result<String, Downl
* # Examples
*
* ```no_run
* use sal::os::download_file;
* use sal_os::download_file;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Download a file with no minimum size requirement
@@ -335,7 +335,7 @@ pub fn download_file(url: &str, dest: &str, min_size_kb: i64) -> Result<String,
* # Examples
*
* ```no_run
* use sal::os::chmod_exec;
* use sal_os::chmod_exec;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Make a file executable
@@ -413,7 +413,7 @@ pub fn chmod_exec(path: &str) -> Result<String, DownloadError> {
* # Examples
*
* ```no_run
* use sal::os::download_install;
* use sal_os::download_install;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Download and install a .deb package

View File

@@ -1,13 +1,13 @@
use dirs;
use libc;
use std::error::Error;
use std::fmt;
use std::fs;
use std::io;
use std::path::Path;
use std::process::Command;
use libc;
use dirs;
#[cfg(not(target_os = "windows"))]
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
use std::process::Command;
// Define a custom error type for file system operations
#[derive(Debug)]
@@ -299,7 +299,7 @@ fn copy_internal(src: &str, dest: &str, make_executable: bool) -> Result<String,
* # Examples
*
* ```no_run
* use sal::os::copy;
* use sal_os::copy;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Copy a single file
@@ -334,7 +334,7 @@ pub fn copy(src: &str, dest: &str) -> Result<String, FsError> {
* # Examples
*
* ```no_run
* use sal::os::copy_bin;
* use sal_os::copy_bin;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Copy a binary
@@ -373,7 +373,7 @@ pub fn copy_bin(src: &str) -> Result<String, FsError> {
* # Examples
*
* ```
* use sal::os::exist;
* use sal_os::exist;
*
* if exist("file.txt") {
* println!("File exists");
@@ -400,7 +400,7 @@ pub fn exist(path: &str) -> bool {
* # Examples
*
* ```no_run
* use sal::os::find_file;
* use sal_os::find_file;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let file_path = find_file("/path/to/dir", "*.txt")?;
@@ -457,7 +457,7 @@ pub fn find_file(dir: &str, filename: &str) -> Result<String, FsError> {
* # Examples
*
* ```no_run
* use sal::os::find_files;
* use sal_os::find_files;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let files = find_files("/path/to/dir", "*.txt")?;
@@ -505,7 +505,7 @@ pub fn find_files(dir: &str, filename: &str) -> Result<Vec<String>, FsError> {
* # Examples
*
* ```no_run
* use sal::os::find_dir;
* use sal_os::find_dir;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let dir_path = find_dir("/path/to/parent", "sub*")?;
@@ -557,7 +557,7 @@ pub fn find_dir(dir: &str, dirname: &str) -> Result<String, FsError> {
* # Examples
*
* ```no_run
* use sal::os::find_dirs;
* use sal_os::find_dirs;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let dirs = find_dirs("/path/to/parent", "sub*")?;
@@ -604,7 +604,7 @@ pub fn find_dirs(dir: &str, dirname: &str) -> Result<Vec<String>, FsError> {
* # Examples
*
* ```
* use sal::os::delete;
* use sal_os::delete;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Delete a file
@@ -652,7 +652,7 @@ pub fn delete(path: &str) -> Result<String, FsError> {
* # Examples
*
* ```
* use sal::os::mkdir;
* use sal_os::mkdir;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let result = mkdir("path/to/new/directory")?;
@@ -693,7 +693,7 @@ pub fn mkdir(path: &str) -> Result<String, FsError> {
* # Examples
*
* ```no_run
* use sal::os::file_size;
* use sal_os::file_size;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let size = file_size("file.txt")?;
@@ -736,7 +736,7 @@ pub fn file_size(path: &str) -> Result<i64, FsError> {
* # Examples
*
* ```no_run
* use sal::os::rsync;
* use sal_os::rsync;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let result = rsync("source_dir/", "backup_dir/")?;
@@ -802,7 +802,7 @@ pub fn rsync(src: &str, dest: &str) -> Result<String, FsError> {
* # Examples
*
* ```no_run
* use sal::os::chdir;
* use sal_os::chdir;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let result = chdir("/path/to/directory")?;
@@ -845,7 +845,7 @@ pub fn chdir(path: &str) -> Result<String, FsError> {
* # Examples
*
* ```no_run
* use sal::os::file_read;
* use sal_os::file_read;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let content = file_read("file.txt")?;
@@ -887,7 +887,7 @@ pub fn file_read(path: &str) -> Result<String, FsError> {
* # Examples
*
* ```
* use sal::os::file_write;
* use sal_os::file_write;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let result = file_write("file.txt", "Hello, world!")?;
@@ -926,7 +926,7 @@ pub fn file_write(path: &str, content: &str) -> Result<String, FsError> {
* # Examples
*
* ```
* use sal::os::file_write_append;
* use sal_os::file_write_append;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* let result = file_write_append("log.txt", "New log entry\n")?;
@@ -974,7 +974,7 @@ pub fn file_write_append(path: &str, content: &str) -> Result<String, FsError> {
* # Examples
*
* ```no_run
* use sal::os::mv;
* use sal_os::mv;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Move a file
@@ -1089,7 +1089,7 @@ pub fn mv(src: &str, dest: &str) -> Result<String, FsError> {
* # Examples
*
* ```
* use sal::os::which;
* use sal_os::which;
*
* let cmd_path = which("ls");
* if cmd_path != "" {
@@ -1133,15 +1133,15 @@ pub fn which(command: &str) -> String {
*
* # Examples
*
* ```
* use sal::os::cmd_ensure_exists;
* ```no_run
* use sal_os::cmd_ensure_exists;
*
* fn main() -> Result<(), Box<dyn std::error::Error>> {
* // Check if a single command exists
* let result = cmd_ensure_exists("nerdctl")?;
* let result = cmd_ensure_exists("ls")?;
*
* // Check if multiple commands exist
* let result = cmd_ensure_exists("nerdctl,docker,containerd")?;
* let result = cmd_ensure_exists("ls,cat,grep")?;
*
* Ok(())
* }