Skip to main content

vs_core/service/
unuse.rs

1use vs_shell::{global_current_dir, project_sdk_dir, remove_existing};
2
3use crate::{App, CoreError, UseScope};
4
5impl App {
6    /// Removes an active tool version from the selected scope.
7    pub fn unuse_tool(&self, plugin_name: &str, scope: UseScope) -> Result<(), CoreError> {
8        match scope {
9            UseScope::Global => {
10                self.write_tool_assignment(
11                    &vs_config::global_tools_file(self.home()),
12                    plugin_name,
13                    None,
14                )?;
15                remove_existing(&global_current_dir(self.home(), plugin_name))?;
16            }
17            UseScope::Project => {
18                self.write_tool_assignment(&self.preferred_project_file(), plugin_name, None)?;
19                remove_existing(&project_sdk_dir(&self.cwd, plugin_name))?;
20            }
21            UseScope::Session => {
22                let session_file = self.session_file()?;
23                self.write_tool_assignment(&session_file, plugin_name, None)?;
24            }
25        }
26        Ok(())
27    }
28}