diff --git a/src/lib.rs b/src/lib.rs index b72a0da..1aacce6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,10 +19,10 @@ mod misc; mod registry; pub async fn init() -> Result<()> { - config::init(); let args = Args::parse(); - let registry = PackageRegistry::new().await?; + config::init(); setup_required_paths().await?; + let registry = PackageRegistry::new().await?; let path_env = env::var("PATH")?; if !path_env.split(':').any(|p| Path::new(p) == *BIN_PATH) { @@ -53,13 +53,7 @@ pub async fn init() -> Result<()> { let portable_config = portable_config.map(|p| p.unwrap_or_default()); registry - .install_packages( - &packages, - force, - portable, - portable_home, - portable_config, - ) + .install_packages(&packages, force, portable, portable_home, portable_config) .await?; } Commands::Sync => { diff --git a/src/registry/mod.rs b/src/registry/mod.rs index a499b55..73d0730 100644 --- a/src/registry/mod.rs +++ b/src/registry/mod.rs @@ -184,7 +184,7 @@ impl PackageRegistry { let formatted_name = format!( "{} ({}#{})", - package.name.clone().color(Color::BrightGreen), + package.bin_name.clone().color(Color::BrightGreen), package.clone().full_name('/').color(Color::BrightCyan), pkg.collection.clone().color(Color::BrightRed) ); @@ -300,10 +300,6 @@ impl PackageRegistry { } for resolved_package in packages { let package = resolved_package.package.clone(); - let variant_prefix = package - .variant - .map(|variant| format!("{}-", variant)) - .unwrap_or_default(); let installed_guard = self.installed_packages.lock().await; let install_prefix = if installed_guard.is_installed(&resolved_package) { "+" @@ -311,10 +307,10 @@ impl PackageRegistry { "-" }; println!( - "[{0}] [{1}] {2}{3}:{3}-{4} ({5})", + "[{0}] [{1}] {2}:{3}-{4} ({5})", install_prefix.color(Color::Red), resolved_package.collection.color(Color::BrightGreen), - variant_prefix.color(Color::Blue), + package.full_name('/').color(Color::Blue), package.name.color(Color::Blue), package.version.color(Color::Green), package.size.color(Color::Magenta) diff --git a/src/registry/package/mod.rs b/src/registry/package/mod.rs index e81a699..7a5f4af 100644 --- a/src/registry/package/mod.rs +++ b/src/registry/package/mod.rs @@ -36,6 +36,7 @@ pub struct Package { pub category: String, pub extra_bins: String, pub icon: String, + pub bin_id: Option, pub variant: Option, } @@ -56,7 +57,7 @@ impl ResolvedPackage { portable: Option, portable_home: Option, portable_config: Option, - multi_progress: Arc + multi_progress: Arc, ) -> Result<()> { let install_path = self.package.get_install_path(&self.package.bsum); let mut installer = Installer::new(self, install_path); @@ -69,7 +70,7 @@ impl ResolvedPackage { portable, portable_home, portable_config, - multi_progress + multi_progress, ) .await?; Ok(()) diff --git a/src/registry/package/update.rs b/src/registry/package/update.rs index 779fc70..60a6e2d 100644 --- a/src/registry/package/update.rs +++ b/src/registry/package/update.rs @@ -88,7 +88,7 @@ impl Updater { None, None, None, - multi_progress.clone() + multi_progress.clone(), ) .await?; update_count += 1; diff --git a/src/registry/storage.rs b/src/registry/storage.rs index f10383f..ab6a5ca 100644 --- a/src/registry/storage.rs +++ b/src/registry/storage.rs @@ -224,7 +224,8 @@ impl PackageStorage { } pub fn list_packages(&self, collection: Option<&str>) -> Vec { - self.repository + let mut packages: Vec = self + .repository .iter() .flat_map(|(repo_name, repo_packages)| { repo_packages @@ -241,7 +242,17 @@ impl PackageStorage { }) }) }) - .collect() + .collect(); + + packages.sort_by(|a, b| { + let collection_cmp = a.collection.cmp(&b.collection); + if collection_cmp == std::cmp::Ordering::Equal { + a.package.full_name('-').cmp(&b.package.full_name('-')) + } else { + collection_cmp + } + }); + packages } pub fn get_packages(&self, query: &PackageQuery) -> Option> {