diff options
| author | Naz <ndpm13@ch-naseem.com> | 2025-07-27 15:18:51 +0100 |
|---|---|---|
| committer | Naz <ndpm13@ch-naseem.com> | 2025-07-27 15:18:51 +0100 |
| commit | a77624b8615a10d6aaba186dcd6bbb15b1419397 (patch) | |
| tree | f6491327240231dabd589752b486e6657d44dca1 /src/types.rs | |
| parent | ebaca23cb9884884dae3121e437c36696570878b (diff) | |
✨feat: add executable symlink creation to ~/.local/bin
Diffstat (limited to 'src/types.rs')
| -rw-r--r-- | src/types.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/types.rs b/src/types.rs index b20ada1..f0cbfd4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -71,4 +71,25 @@ impl AppImage { Ok(()) } + pub async fn create_symlink(&self) -> Result<(), Box<dyn std::error::Error>> { + let home = std::env::var("HOME")?; + let local_bin = PathBuf::from(home).join(".local/bin"); + + fs::create_dir_all(&local_bin).await?; + + let symlink_path = local_bin.join(&self.executable); + + #[cfg(unix)] + { + use tokio::fs; + + if symlink_path.exists() { + fs::remove_file(&symlink_path).await?; + } + + std::os::unix::fs::symlink(&self.file_path, &symlink_path)?; + } + + Ok(()) + } } |
