pub mod commands;
pub mod features;
pub mod options {}
pub mod registry;
use clientele::{StandardOptions, SysexitsError};
pub(crate) fn sort_links(module_name: &str, links: &mut [impl AsRef<str>]) {
use std::cmp::Reverse;
links.sort_by_cached_key(|link| {
let Ok(url) = reqwest::Url::parse(link.as_ref()) else {
return Reverse(0);
};
let Some(host) = url.host_str() else {
return Reverse(0);
};
let our_module = link.as_ref().contains("github.com/asimov-modules/") as i8;
let host_score =
(host.ends_with("github.com") as i8 * 2)
+ ((host.ends_with("crates.io") ||
host.ends_with("pypi.org") ||
host.ends_with("rubygems.org") ||
host.ends_with("npmjs.com")) as i8);
let path_score = {
let path = url.path();
(path.contains(&format!("asimov-{module_name}-module")) as i8 * 3)
+ (((path.contains("asimov-")
&& path.contains("-module")
&& !path.contains("/asimov-modules/")) as i8) * 2)
+ (path.contains("/asimov-modules/") as i8)
};
Reverse(our_module * 5 + host_score + path_score + 1)
});
}