Skip to content

Commit

Permalink
added mac uninstall function
Browse files Browse the repository at this point in the history
  • Loading branch information
cqb13 committed Jan 9, 2024
1 parent a700c2b commit d8aeaec
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
15 changes: 9 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
pub mod commands;
pub mod config;
pub mod display;
pub mod install;
pub mod scan;
pub mod utils;

pub mod system {
pub mod config;
pub mod local;
}

use crate::commands::arg_tokenizer;
use crate::config::{
use crate::display::display;
use crate::scan::scan;
use crate::system::config::{
add_value_to_setting, create_config_file, get_setting_from_config, remove_value_from_setting,
ConfigOption,
};
use crate::display::display;
use crate::install::install;
use crate::scan::scan;
use crate::system::local::install;
use crate::utils::get_current_directory_path;
use std::env;

Expand Down
File renamed without changes.
29 changes: 26 additions & 3 deletions src/install.rs → src/system/local.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::config::get_user_home_dir;
use crate::system::config::get_user_home_dir;
use crate::utils::get_current_directory_path;
use crate::OS;
use std::io::Write;
Expand Down Expand Up @@ -34,7 +34,7 @@ pub fn install(os: &OS) {
.unwrap();
}

if let Err(e) = modify_registry_path(&app_data_path) {
if let Err(e) = add_registry_path(&app_data_path) {
eprintln!("Failed to modify system PATH: {}", e);
eprintln!("This action may require administrator permissions.");
return;
Expand Down Expand Up @@ -82,7 +82,30 @@ pub fn install(os: &OS) {
println!("install complete");
}

fn modify_registry_path(new_path: &str) -> std::io::Result<()> {
pub fn uninstall(os: &OS) {
println!("starting uninstall on {}", os.get_name());

let home_dir = get_user_home_dir(os);

match os {
OS::Windows => {
println!("uninstalling on windows");
}
OS::Mac => {
let local_bin_path = format!("{}/.local/bin", home_dir);
if std::path::Path::new(&local_bin_path).exists() {
println!("removing binary from .local/bin");
std::fs::remove_file(&local_bin_path).unwrap();
}

// path is not removed as their may be other binaries later added into the directory
}
}

println!("uninstall complete");
}

fn add_registry_path(new_path: &str) -> std::io::Result<()> {
use std::process::Command;

// Escape percent signs by doubling them
Expand Down
2 changes: 2 additions & 0 deletions src/system/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod config;
pub mod local;

0 comments on commit d8aeaec

Please sign in to comment.