Struct proto_core::Tool
source · pub struct Tool {Show 16 fields
pub id: Id,
pub manifest: ToolManifest,
pub metadata: ToolMetadataOutput,
pub locator: Option<PluginLocator>,
pub plugin: Arc<PluginContainer>,
pub proto: Arc<ProtoEnvironment>,
pub version: Option<VersionSpec>,
pub on_created_bins: Emitter<CreatedBinariesEvent>,
pub on_created_shims: Emitter<CreatedShimsEvent>,
pub on_installing: Emitter<InstallingEvent>,
pub on_installed: Emitter<InstalledEvent>,
pub on_installed_global: Emitter<InstalledGlobalEvent>,
pub on_resolved_version: Emitter<ResolvedVersionEvent>,
pub on_uninstalling: Emitter<UninstallingEvent>,
pub on_uninstalled: Emitter<UninstalledEvent>,
pub on_uninstalled_global: Emitter<UninstalledGlobalEvent>,
/* private fields */
}
Fields§
§id: Id
§manifest: ToolManifest
§metadata: ToolMetadataOutput
§locator: Option<PluginLocator>
§plugin: Arc<PluginContainer>
§proto: Arc<ProtoEnvironment>
§version: Option<VersionSpec>
§on_created_bins: Emitter<CreatedBinariesEvent>
§on_created_shims: Emitter<CreatedShimsEvent>
§on_installing: Emitter<InstallingEvent>
§on_installed: Emitter<InstalledEvent>
§on_installed_global: Emitter<InstalledGlobalEvent>
§on_resolved_version: Emitter<ResolvedVersionEvent>
§on_uninstalling: Emitter<UninstallingEvent>
§on_uninstalled: Emitter<UninstalledEvent>
§on_uninstalled_global: Emitter<UninstalledGlobalEvent>
Implementations§
source§impl Tool
impl Tool
pub fn new( id: Id, proto: Arc<ProtoEnvironment>, plugin: Arc<PluginContainer> ) -> Result<Self>
pub fn load<I: AsRef<Id>, P: AsRef<ProtoEnvironment>>( id: I, proto: P, wasm: Wasm ) -> Result<Self>
pub fn load_from_manifest<I: AsRef<Id>, P: AsRef<ProtoEnvironment>>( id: I, proto: P, manifest: PluginManifest ) -> Result<Self>
pub fn create_plugin_manifest<P: AsRef<ProtoEnvironment>>( proto: P, wasm: Wasm ) -> Result<PluginManifest>
sourcepub fn disable_caching(&mut self)
pub fn disable_caching(&mut self)
Disable internal caching when applicable.
sourcepub fn get_env_var_prefix(&self) -> String
pub fn get_env_var_prefix(&self) -> String
Return the prefix for environment variable names.
sourcepub fn get_inventory_dir(&self) -> PathBuf
pub fn get_inventory_dir(&self) -> PathBuf
Return an absolute path to the tool’s inventory directory. The inventory houses installed versions, the manifest, and more.
sourcepub fn get_resolved_version(&self) -> VersionSpec
pub fn get_resolved_version(&self) -> VersionSpec
Return the resolved version or “latest”.
sourcepub fn get_temp_dir(&self) -> PathBuf
pub fn get_temp_dir(&self) -> PathBuf
Return an absolute path to a temp directory solely for this tool.
sourcepub fn get_tool_dir(&self) -> PathBuf
pub fn get_tool_dir(&self) -> PathBuf
Return an absolute path to the tool’s install directory for the currently resolved version.
sourcepub fn set_version(&mut self, version: VersionSpec)
pub fn set_version(&mut self, version: VersionSpec)
Explicitly set the version to use.
sourcepub fn disable_progress_bars(&self) -> bool
pub fn disable_progress_bars(&self) -> bool
Disable progress bars when installing or uninstalling the tool.
sourcepub fn from_virtual_path(&self, path: &Path) -> PathBuf
pub fn from_virtual_path(&self, path: &Path) -> PathBuf
Convert a virtual path to a real path.
sourcepub fn to_virtual_path(&self, path: &Path) -> VirtualPath
pub fn to_virtual_path(&self, path: &Path) -> VirtualPath
Convert a real path to a virtual path.
source§impl Tool
impl Tool
sourcepub fn create_context(&self) -> ToolContext
pub fn create_context(&self) -> ToolContext
Return contextual information to pass to WASM plugin functions.
sourcepub fn register_tool(&mut self) -> Result<()>
pub fn register_tool(&mut self) -> Result<()>
Register the tool by loading initial metadata and persisting it.
sourcepub fn run_hook<I>(&self, hook: &str, input: impl FnOnce() -> I) -> Result<()>
pub fn run_hook<I>(&self, hook: &str, input: impl FnOnce() -> I) -> Result<()>
Run a hook with the provided name and input.
sourcepub fn sync_manifest(&mut self) -> Result<()>
pub fn sync_manifest(&mut self) -> Result<()>
Sync the local tool manifest with changes from the plugin.
source§impl Tool
impl Tool
sourcepub async fn load_version_resolver(
&self,
initial_version: &UnresolvedVersionSpec
) -> Result<VersionResolver<'_>>
pub async fn load_version_resolver( &self, initial_version: &UnresolvedVersionSpec ) -> Result<VersionResolver<'_>>
Load available versions to install and return a resolver instance. To reduce network overhead, results will be cached for 24 hours.
sourcepub async fn resolve_version(
&mut self,
initial_version: &UnresolvedVersionSpec,
short_circuit: bool
) -> Result<()>
pub async fn resolve_version( &mut self, initial_version: &UnresolvedVersionSpec, short_circuit: bool ) -> Result<()>
Given an initial version, resolve it to a fully qualifed and semantic version (or alias) according to the tool’s ecosystem.
sourcepub async fn detect_version_from(
&self,
current_dir: &Path
) -> Result<Option<(UnresolvedVersionSpec, PathBuf)>>
pub async fn detect_version_from( &self, current_dir: &Path ) -> Result<Option<(UnresolvedVersionSpec, PathBuf)>>
Attempt to detect an applicable version from the provided directory.
source§impl Tool
impl Tool
sourcepub fn is_installed(&self) -> bool
pub fn is_installed(&self) -> bool
Return true if the tool has been installed. This is less accurate than is_setup
,
as it only checks for the existence of the inventory directory.
sourcepub async fn verify_checksum(
&self,
checksum_file: &Path,
download_file: &Path,
checksum_public_key: Option<&str>
) -> Result<bool>
pub async fn verify_checksum( &self, checksum_file: &Path, download_file: &Path, checksum_public_key: Option<&str> ) -> Result<bool>
Verify the downloaded file using the checksum strategy for the tool. Common strategies are SHA256 and MD5.
pub async fn build_from_source(&self, install_dir: &Path) -> Result<()>
sourcepub async fn install_from_prebuilt(&self, install_dir: &Path) -> Result<()>
pub async fn install_from_prebuilt(&self, install_dir: &Path) -> Result<()>
Download the tool (as an archive) from its distribution registry
into the ~/.proto/tools/<version>
folder, and optionally verify checksums.
sourcepub async fn install(&mut self, _build: bool) -> Result<bool>
pub async fn install(&mut self, _build: bool) -> Result<bool>
Install a tool into proto, either by downloading and unpacking a pre-built archive, or by using a native installation method.
sourcepub async fn install_global(&self, dependency: &str) -> Result<bool>
pub async fn install_global(&self, dependency: &str) -> Result<bool>
Install a global dependency/package for the tool.
sourcepub async fn uninstall(&self) -> Result<bool>
pub async fn uninstall(&self) -> Result<bool>
Uninstall the tool by deleting the current install directory.
sourcepub async fn uninstall_global(&self, dependency: &str) -> Result<bool>
pub async fn uninstall_global(&self, dependency: &str) -> Result<bool>
Uninstall a global dependency/package from the tool.
source§impl Tool
impl Tool
sourcepub async fn create_executables(
&mut self,
force_shims: bool,
force_bins: bool
) -> Result<()>
pub async fn create_executables( &mut self, force_shims: bool, force_bins: bool ) -> Result<()>
Create all executables for the current tool.
- Locate the primary binary to execute.
- Generate shims to
~/.proto/shims
. - Symlink bins to
~/.proto/bin
.
sourcepub fn get_exe_path(&self) -> Result<&Path>
pub fn get_exe_path(&self) -> Result<&Path>
Return an absolute path to the executable file for the tool.
sourcepub fn get_globals_bin_dir(&self) -> Option<&Path>
pub fn get_globals_bin_dir(&self) -> Option<&Path>
Return an absolute path to the globals directory in which packages are installed to.
sourcepub fn get_globals_prefix(&self) -> Option<&str>
pub fn get_globals_prefix(&self) -> Option<&str>
Return a string that all globals are prefixed with. Will be used for filtering and listing.
sourcepub fn get_bin_locations(&self) -> Result<Vec<ExecutableLocation>>
pub fn get_bin_locations(&self) -> Result<Vec<ExecutableLocation>>
Return a list of all binaries that get created in ~/.proto/bin
.
The list will contain the executable config, and an absolute path
to the binaries final location.
sourcepub fn get_exe_location(&self) -> Result<Option<ExecutableLocation>>
pub fn get_exe_location(&self) -> Result<Option<ExecutableLocation>>
Return location information for the primary executable within the tool directory.
sourcepub fn get_shim_locations(&self) -> Result<Vec<ExecutableLocation>>
pub fn get_shim_locations(&self) -> Result<Vec<ExecutableLocation>>
Return a list of all shims that get created in ~/.proto/shims
.
The list will contain the executable config, and an absolute path
to the shims final location.
sourcepub async fn locate_executable(&mut self) -> Result<()>
pub async fn locate_executable(&mut self) -> Result<()>
Locate the primary executable from the tool directory.
sourcepub async fn locate_globals_dir(&mut self) -> Result<()>
pub async fn locate_globals_dir(&mut self) -> Result<()>
Locate the directory that global packages are installed to.
sourcepub async fn generate_shims(&mut self, force: bool) -> Result<()>
pub async fn generate_shims(&mut self, force: bool) -> Result<()>
Create shim files for the current tool if they are missing or out of date. If find only is enabled, will only check if they exist, and not create.
sourcepub async fn symlink_bins(&mut self, force: bool) -> Result<()>
pub async fn symlink_bins(&mut self, force: bool) -> Result<()>
Symlink all primary and secondary binaries for the current tool.
source§impl Tool
impl Tool
sourcepub async fn is_setup(
&mut self,
initial_version: &UnresolvedVersionSpec
) -> Result<bool>
pub async fn is_setup( &mut self, initial_version: &UnresolvedVersionSpec ) -> Result<bool>
Return true if the tool has been setup (installed and binaries are located).
sourcepub async fn setup(
&mut self,
initial_version: &UnresolvedVersionSpec,
build_from_source: bool
) -> Result<bool>
pub async fn setup( &mut self, initial_version: &UnresolvedVersionSpec, build_from_source: bool ) -> Result<bool>
Setup the tool by resolving a semantic version, installing the tool, locating binaries, creating shims, and more.
Auto Trait Implementations§
impl !RefUnwindSafe for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl !UnwindSafe for Tool
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more