Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tags to the runtime metadata #87

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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