Browse Source

Added Self Uninstall Command

tags/v0.3.12-rc0
Shar-jeel-Sajid 9 months ago
parent
commit
9037ca8796
3 changed files with 45 additions and 1 deletions
  1. +12
    -0
      Cargo.lock
  2. +1
    -0
      binaries/cli/Cargo.toml
  3. +32
    -1
      binaries/cli/src/lib.rs

+ 12
- 0
Cargo.lock View File

@@ -3087,6 +3087,7 @@ dependencies = [
"log",
"notify 5.2.0",
"pyo3",
"self-replace",
"self_update",
"serde",
"serde_json",
@@ -11989,6 +11990,17 @@ dependencies = [
"libc",
]

[[package]]
name = "self-replace"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03ec815b5eab420ab893f63393878d89c90fdd94c0bcc44c07abb8ad95552fb7"
dependencies = [
"fastrand 2.3.0",
"tempfile",
"windows-sys 0.52.0",
]

[[package]]
name = "self_update"
version = "0.27.0"


+ 1
- 0
binaries/cli/Cargo.toml View File

@@ -60,6 +60,7 @@ pyo3 = { workspace = true, features = [
"extension-module",
"abi3",
], optional = true }
self-replace = "1.5.0"


[lib]


+ 32
- 1
binaries/cli/src/lib.rs View File

@@ -240,7 +240,7 @@ enum Command {
#[clap(long)]
quiet: bool,
},
/// Dora CLI self-management commands
Self_ {
#[clap(subcommand)]
command: SelfSubCommand,
@@ -249,11 +249,18 @@ enum Command {

#[derive(Debug, clap::Subcommand)]
enum SelfSubCommand {
/// Check for updates or update the CLI
Update {
/// Only check for updates without installing
#[clap(long)]
check_only: bool,
},
/// Remove The Dora CLI from the system
Uninstall {
/// Force uninstallation without confirmation
#[clap(long)]
force: bool,
},
}

#[derive(Debug, clap::Args)]
@@ -606,6 +613,30 @@ fn run(args: Args) -> eyre::Result<()> {
}
}
}
SelfSubCommand::Uninstall { force } => {
if !force {
let confirmed =
inquire::Confirm::new("Are you sure you want to uninstall Dora CLI?")
.with_default(false)
.prompt()
.wrap_err("Uninstallation cancelled")?;

if !confirmed {
println!("Uninstallation cancelled");
return Ok(());
}
}

println!("Uninstalling Dora CLI...");
match self_replace::self_delete() {
Ok(_) => {
println!("Dora CLI has been successfully uninstalled.");
}
Err(e) => {
bail!("Failed to uninstall Dora CLI: {}", e);
}
}
}
},
};



Loading…
Cancel
Save