Skip to content

Commit

Permalink
Merge pull request #786 from uncomfyhalomacro/20240112-improvement-of…
Browse files Browse the repository at this point in the history
…-self-uninstall-take-2

improvement: new message for `juliaup self uninstall command` if feature `selfupdate` is disabled
  • Loading branch information
davidanthoff authored Jan 13, 2024
2 parents 9d82046 + d98547a commit 2475fb3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/bin/juliaup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ use juliaup::{
command_config_backgroundselfupdate::run_command_config_backgroundselfupdate,
command_config_modifypath::run_command_config_modifypath,
command_config_startupselfupdate::run_command_config_startupselfupdate,
command_selfchannel::run_command_selfchannel, command_selfuninstall::run_command_selfuninstall,
command_selfchannel::run_command_selfchannel,
};

#[cfg(feature = "selfupdate")]
use juliaup::command_selfuninstall::run_command_selfuninstall;

#[cfg(not(feature = "selfupdate"))]
use juliaup::command_selfuninstall::run_command_selfuninstall_unavailable;

use log::info;

#[derive(Parser)]
Expand Down Expand Up @@ -113,6 +120,9 @@ enum SelfSubCmd {
#[cfg(feature = "selfupdate")]
/// Uninstall this version of juliaup from the system
Uninstall {},
#[cfg(not(feature = "selfupdate"))]
/// Uninstall this version of juliaup from the system (UNAVAILABLE)
Uninstall {},
}

#[derive(Parser)]
Expand Down Expand Up @@ -226,6 +236,8 @@ fn main() -> Result<()> {
SelfSubCmd::Channel { channel } => run_command_selfchannel(channel, &paths),
#[cfg(feature = "selfupdate")]
SelfSubCmd::Uninstall {} => run_command_selfuninstall(&paths),
#[cfg(not(feature = "selfupdate"))]
SelfSubCmd::Uninstall {} => run_command_selfuninstall_unavailable(),
},
}
}
13 changes: 13 additions & 0 deletions src/command_selfuninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,16 @@ pub fn run_command_selfuninstall(paths: &crate::global_paths::GlobalPaths) -> Re

Ok(())
}

#[cfg(not(feature = "selfupdate"))]
use anyhow::Result;

#[cfg(not(feature = "selfupdate"))]
pub fn run_command_selfuninstall_unavailable() -> Result<()> {
eprintln!(
"Self uninstall command is unavailable in this variant of Juliaup.
This software was built with the intention of distributing it
through a package manager other than cargo or upstream."
);
Ok(())
}

0 comments on commit 2475fb3

Please sign in to comment.