Skip to content

Commit

Permalink
feat: add tags to the runtime metadata (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelmmiguel authored Feb 13, 2023
1 parent 9752cf2 commit a23438f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/commands/runtimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]));
Expand Down Expand Up @@ -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;
}
Expand All @@ -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),
]));
Expand Down
9 changes: 6 additions & 3 deletions src/runtimes/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
})
}
}

Expand All @@ -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<String>,
/// Current status in the repository
pub status: RuntimeStatus,
/// Associated extensions
Expand Down

0 comments on commit a23438f

Please sign in to comment.