Use upgrade-specific output for tool upgrade (#5997)

## Summary

Closes https://github.com/astral-sh/uv/issues/5949.
This commit is contained in:
Charlie Marsh 2024-08-10 20:24:49 -04:00 committed by GitHub
parent f5110f7b5e
commit ec8248ff93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 222 additions and 76 deletions

View file

@ -124,6 +124,24 @@ pub enum InstalledVersion<'a> {
Url(&'a Url, &'a Version),
}
impl<'a> InstalledVersion<'a> {
/// If it is a URL, return its value.
pub fn url(&self) -> Option<&Url> {
match self {
InstalledVersion::Version(_) => None,
InstalledVersion::Url(url, _) => Some(url),
}
}
/// If it is a version, return its value.
pub fn version(&self) -> &Version {
match self {
InstalledVersion::Version(version) => version,
InstalledVersion::Url(_, version) => version,
}
}
}
impl std::fmt::Display for InstalledVersion<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {