From 648b48d121a0225753cd9c14e535287ef59b7615 Mon Sep 17 00:00:00 2001 From: Angel M De Miguel Date: Mon, 13 Feb 2023 10:28:52 +0100 Subject: [PATCH] feat: add tags to the runtime metadata --- src/commands/runtimes.rs | 15 +++++++++++++++ src/runtimes/metadata.rs | 9 ++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/commands/runtimes.rs b/src/commands/runtimes.rs index 0089422c..73581885 100644 --- a/src/commands/runtimes.rs +++ b/src/commands/runtimes.rs @@ -160,14 +160,22 @@ impl List { table.add_row(Row::new(vec![ Cell::new("Name"), Cell::new("Version"), + Cell::new("Tags"), Cell::new("Extension"), Cell::new("Binary"), ])); for runtime in &repo.runtimes { + let mut tags = runtime.tags.join(", "); + + if tags.is_empty() { + tags.push('-'); + } + table.add_row(Row::new(vec![ Cell::new(&runtime.name), Cell::new(&runtime.version), + Cell::new(&tags), Cell::new(&runtime.extensions.join(", ")), Cell::new(&runtime.binary.filename), ])); @@ -199,14 +207,20 @@ impl Check { Cell::new("Installed"), Cell::new("Name"), Cell::new("Version"), + Cell::new("Tags"), Cell::new("Extension"), Cell::new("Binary"), ])); for repo in &config.repositories { for runtime in &repo.runtimes { + let mut tags = runtime.tags.join(", "); let is_installed = check_runtime(project_root, &repo.name, runtime); + if tags.is_empty() { + tags.push('-'); + } + if !is_installed { is_missing = true; } @@ -215,6 +229,7 @@ impl Check { Cell::new(if is_installed { "✅" } else { "❌" }), Cell::new(&runtime.name), Cell::new(&runtime.version), + Cell::new(&tags), Cell::new(&runtime.extensions.join(", ")), Cell::new(&runtime.binary.filename), ])); diff --git a/src/runtimes/metadata.rs b/src/runtimes/metadata.rs index e5cad75a..e142d1c4 100644 --- a/src/runtimes/metadata.rs +++ b/src/runtimes/metadata.rs @@ -62,9 +62,9 @@ impl Repository { } pub fn find_runtime(&self, name: &str, version: &str) -> Option<&Runtime> { - self.runtimes - .iter() - .find(|r| r.name == name && r.version == version) + self.runtimes.iter().find(|r| { + r.name == name && (r.version == version || r.tags.contains(&String::from(version))) + }) } } @@ -82,6 +82,9 @@ pub struct Runtime { pub name: String, /// Specific version of the runtime pub version: String, + /// Optional aliases for the version + #[serde(default)] + pub tags: Vec, /// Current status in the repository pub status: RuntimeStatus, /// Associated extensions