Skip to content
Merged
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions src/cli/args/backend_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,22 @@ impl BackendArg {
bail!("{plugin_name} is not a valid plugin name");
}
} else {
// Check if the tool is in the registry but has no available backends
if let Some(rt) = REGISTRY.get(self.short.as_str()) {
if rt.backends().is_empty() && !rt.backends.is_empty() {
let all_backends: Vec<&str> = rt.backends.iter().map(|rb| rb.full).collect();
bail!(
"{self} is in the mise tool registry but none of its backends ({}) are supported on this platform",
all_backends.join(", ")
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve performance and code clarity, you can use itertools::Itertools::join to avoid the intermediate Vec allocation. This requires adding use itertools::Itertools; to the file's imports.

Suggested change
let all_backends: Vec<&str> = rt.backends.iter().map(|rb| rb.full).collect();
bail!(
"{self} is in the mise tool registry but none of its backends ({}) are supported on this platform",
all_backends.join(", ")
);
let all_backends = rt.backends.iter().map(|rb| rb.full).join(", ");
bail!(
"{self} is in the mise tool registry but none of its backends ({}) are supported on this platform",
all_backends
);

}
}

let registry_shorts: Vec<&str> = REGISTRY.keys().copied().collect();
let mut suggestions: Vec<String> =
xx::suggest::similar_n_with_threshold(&self.short, &registry_shorts, 3, 0.8)
.into_iter()
.filter(|s| *s != self.short)
.map(|s| s.to_string())
.collect();

Expand Down
Loading