Skip to content

Commit

Permalink
fix: uninstall casks and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelessiet committed Nov 18, 2024
1 parent ef46c19 commit 39cb6bd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bert"
version = "0.1.8"
version = "0.1.9"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async fn main() -> Result<()> {
self_update::self_update().await?;
}
Some(Commands::Uninstall { package }) => {
package_manager::uninstall_package(&package).await?;
package_manager::uninstall_package(&package, cli.cask).await?;
}
Some(Commands::Install { package }) => {
// Parse package name and version
Expand Down
6 changes: 3 additions & 3 deletions src/package_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use anyhow::Result;
use colored::*;
use std::process::Command;

pub async fn uninstall_package(name: &str) -> Result<()> {
pub async fn uninstall_package(name: &str, is_cask: bool) -> Result<()> {
if !crate::homebrew::is_homebrew_installed().await {
anyhow::bail!("Homebrew is not installed");
}

// First check if the package is installed
let installed = Command::new(if cfg!(windows) { "brew.exe" } else { "brew" })
.args(["list", "--versions", name])
.args(["list", "--versions", name, if is_cask { "--cask" } else {""}])
.output()?;

if !installed.status.success() || installed.stdout.is_empty() {
Expand All @@ -24,7 +24,7 @@ pub async fn uninstall_package(name: &str) -> Result<()> {
println!("Uninstalling {}...", name.cyan());

let status = Command::new(if cfg!(windows) { "brew.exe" } else { "brew" })
.args(["uninstall", name])
.args(["uninstall", name, if is_cask { "--cask" } else {""}])
.status()?;

if !status.success() {
Expand Down

0 comments on commit 39cb6bd

Please sign in to comment.