summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/args.rs9
-rw-r--r--src/types.rs19
2 files changed, 24 insertions, 4 deletions
diff --git a/src/args.rs b/src/args.rs
index 274bb1e..7f7ca3a 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -13,6 +13,10 @@ pub enum Command {
/// Installs an AppImage
#[command(name = "install", alias = "i")]
Install(InstallArgs),
+
+ /// Removes an AppImage
+ #[command(name = "remove", alias = "rm")]
+ Remove(RemoveArgs),
}
#[derive(Debug, Args)]
@@ -27,3 +31,8 @@ pub struct InstallArgs {
#[arg(long)]
pub executable: Option<String>,
}
+
+#[derive(Debug, Args)]
+pub struct RemoveArgs {
+ pub appname: String,
+}
diff --git a/src/types.rs b/src/types.rs
index f0cbfd4..be3f3ed 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -1,24 +1,24 @@
use futures_util::StreamExt;
-use serde::Serialize;
+use serde::{Serialize, Deserialize};
use std::path::PathBuf;
use tokio::{fs, io::AsyncWriteExt};
use crate::{appimages_dir, index_dir, make_progress_bar};
-#[derive(Debug, Serialize)]
+#[derive(Debug, Serialize, Deserialize)]
pub struct AppImage {
pub file_path: PathBuf,
pub executable: String,
pub source: Source,
}
-#[derive(Debug, Serialize)]
+#[derive(Debug, Serialize, Deserialize)]
pub struct Source {
pub identifier: String,
pub meta: SourceMetadata,
}
-#[derive(Debug, Serialize)]
+#[derive(Debug, Serialize, Deserialize)]
pub struct SourceMetadata {
pub url: String,
}
@@ -92,4 +92,15 @@ impl AppImage {
Ok(())
}
+ pub async fn remove(&self) -> Result<(), Box<dyn std::error::Error>> {
+ let home = std::env::var("HOME")?;
+ let symlink_path = PathBuf::from(home).join(".local/bin").join(&self.executable);
+ let index_path = index_dir().join(format!("{}.json", &self.executable));
+
+ fs::remove_file(&self.file_path).await?;
+ fs::remove_file(symlink_path).await?;
+ fs::remove_file(index_path).await?;
+
+ Ok(())
+ }
}