diff --git a/src/sync.rs b/src/sync.rs index 936a975..2b30de0 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -44,6 +44,7 @@ For more details, refer to the official documentation: } const DONE: Emoji<'_, '_> = Emoji("✨ ", "* "); +const DIRECTORY: Emoji<'_, '_> = Emoji("📁 ", "* "); fn sync_tools(config: Config) { let store_directory = config.ensure_store_directory(); @@ -58,7 +59,7 @@ fn sync_tools(config: Config) { .collect(); let sync_progress = SyncProgress::new(tool_pairs); - let installer = Installer::mk(store_directory, sync_progress); + let installer = Installer::mk(store_directory.as_path(), sync_progress); let mut installed_tools: u64 = 0; @@ -70,4 +71,9 @@ fn sync_tools(config: Config) { } eprintln!("{} Successfully installed {} tools!", DONE, installed_tools); + eprintln!( + "{} Installation directory: {}", + DIRECTORY, + store_directory.display() + ); } diff --git a/src/sync/install.rs b/src/sync/install.rs index 795f059..1bd6fc2 100644 --- a/src/sync/install.rs +++ b/src/sync/install.rs @@ -1,7 +1,7 @@ use indicatif::ProgressBar; use std::error::Error; use std::fs; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use tempdir::TempDir; #[cfg(target_family = "unix")] @@ -15,16 +15,16 @@ use super::archive::Archive; use super::download::Downloader; use super::progress::SyncProgress; -pub struct Installer { - store_directory: PathBuf, +pub struct Installer<'a> { + store_directory: &'a Path, tmp_dir: TempDir, sync_progress: SyncProgress, } -impl Installer { +impl<'a> Installer<'a> { /// This functions panics when it can't create a temporary directory /// (e.g. not enough disk space?) - pub fn mk(store_directory: PathBuf, sync_progress: SyncProgress) -> Installer { + pub fn mk(store_directory: &Path, sync_progress: SyncProgress) -> Installer { let tmp_dir = TempDir::new("tool-sync"); match tmp_dir { Err(e) => { @@ -84,7 +84,7 @@ impl Installer { Some(archive) => match archive.unpack() { Err(unpack_err) => Err(unpack_err.display().into()), Ok(tool_path) => { - copy_file(tool_path, &self.store_directory, &tool_asset.exe_name)?; + copy_file(tool_path, self.store_directory, &tool_asset.exe_name)?; Ok(()) } }, @@ -92,7 +92,7 @@ impl Installer { } } -fn copy_file(tool_path: PathBuf, store_directory: &PathBuf, exe_name: &str) -> std::io::Result<()> { +fn copy_file(tool_path: PathBuf, store_directory: &Path, exe_name: &str) -> std::io::Result<()> { let exe_name = mk_exe_name(exe_name); let mut install_path = PathBuf::new(); diff --git a/src/sync/prefetch.rs b/src/sync/prefetch.rs index bd71ec3..1040ef3 100644 --- a/src/sync/prefetch.rs +++ b/src/sync/prefetch.rs @@ -87,7 +87,7 @@ pub fn prefetch(tools: BTreeMap) -> Vec { let estimated_download_size: u64 = tool_assets.iter().map(|ta| ta.asset.size).sum(); let size = HumanBytes(estimated_download_size); eprintln!( - "{emoji} Estimated download size: {size}", + "{emoji} Estimated total download size: {size}", emoji = PACKAGE, size = size );