Skip to main content

vs_core/service/
cd.rs

1use crate::{App, CoreError};
2
3impl App {
4    /// Returns the active home directory path.
5    pub fn home_dir(&self) -> String {
6        self.home().display().to_string()
7    }
8
9    /// Prints the active runtime directory for a tool.
10    pub fn cd_path(&self, plugin_name: &str) -> Result<String, CoreError> {
11        let current = self
12            .current_tool(plugin_name)?
13            .ok_or_else(|| CoreError::InactiveTool(plugin_name.to_string()))?;
14        Ok(self.effective_runtime_dir(&current).display().to_string())
15    }
16
17    /// Returns the local plugin source directory.
18    pub fn plugin_dir(&self, plugin_name: &str) -> Result<String, CoreError> {
19        let entry = self.resolve_registry_entry(plugin_name)?;
20        let entry = self.materialize_plugin_entry(&entry)?;
21        Ok(self
22            .normalize_source_path(&entry.source)
23            .display()
24            .to_string())
25    }
26}