use crate::platform::PerlInterpreterResult;
use std::path::Path;
fn detect_perl_version_cached(perl_path: &Path) -> Option<String> {
perl_lsp_rs_core::config::PerlToolchainProfile::from_binary(perl_path.to_path_buf()).version()
}
pub(super) fn detect_perl_info() -> String {
match crate::platform::find_perl_interpreter_cached(None) {
PerlInterpreterResult::ConfiguredPath(path)
| PerlInterpreterResult::FoundOnPath(path)
| PerlInterpreterResult::FoundViaFallback { path, .. } => {
match detect_perl_version_cached(&path) {
Some(v) if !v.trim().is_empty() => {
format!("Found Perl at {} (version {})", path.display(), v.trim())
}
_ => format!("Found Perl at {}", path.display()),
}
}
PerlInterpreterResult::NotFound { .. } => {
#[cfg(windows)]
{
"Perl was not found on PATH. Install Perl from https://strawberryperl.com \
or set a custom path."
.to_string()
}
#[cfg(not(windows))]
{
"Perl was not found on PATH. Install Perl via your package manager \
(e.g. `apt install perl` or `brew install perl`) or set a custom path."
.to_string()
}
}
}
}