mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-02 06:51:14 +00:00
Show symbolic links in uv python list
(#5343)
## Summary This PR displays symbolic links in `uv python list` and produces output similar to the following: ``` :) uv python list --preview cpython-3.12.1-macos-aarch64-none /Users/eth/workspace/astral-sh/uv/bin/python3.12 -> versions/cpython@3.12.1/install/bin/python3 cpython-3.12.1-macos-aarch64-none /Users/eth/workspace/astral-sh/uv/bin/python3 -> versions/cpython@3.12.1/install/bin/python3 cpython-3.12.1-macos-aarch64-none /Users/eth/workspace/astral-sh/uv/bin/python -> versions/cpython@3.12.1/install/bin/python3 cpython-3.11.7-macos-aarch64-none /Users/eth/workspace/astral-sh/uv/bin/python3.11 -> versions/cpython@3.11.7/install/bin/python3 cpython-3.10.13-macos-aarch64-none /Users/eth/workspace/astral-sh/uv/bin/python3.10 -> versions/cpython@3.10.13/install/bin/python3 cpython-3.9.18-macos-aarch64-none /Users/eth/workspace/astral-sh/uv/bin/python3.9 -> versions/cpython@3.9.18/install/bin/python3 cpython-3.8.18-macos-aarch64-none /Users/eth/workspace/astral-sh/uv/bin/python3.8 -> versions/cpython@3.8.18/install/bin/python3 ``` Resolves #5308 ## Test Plan ``` $ cargo run python list ```
This commit is contained in:
parent
0f8186d9ad
commit
e05d653a71
1 changed files with 15 additions and 5 deletions
|
@ -142,11 +142,21 @@ pub(crate) async fn list(
|
||||||
for (key, path) in include {
|
for (key, path) in include {
|
||||||
let key = key.to_string();
|
let key = key.to_string();
|
||||||
if let Some(path) = path {
|
if let Some(path) = path {
|
||||||
|
let is_symlink = fs_err::symlink_metadata(path)?.is_symlink();
|
||||||
|
if is_symlink {
|
||||||
|
writeln!(
|
||||||
|
printer.stdout(),
|
||||||
|
"{key:width$} {} -> {}",
|
||||||
|
path.user_display().cyan(),
|
||||||
|
path.read_link()?.user_display().cyan()
|
||||||
|
)?;
|
||||||
|
} else {
|
||||||
writeln!(
|
writeln!(
|
||||||
printer.stdout(),
|
printer.stdout(),
|
||||||
"{key:width$} {}",
|
"{key:width$} {}",
|
||||||
path.user_display().cyan()
|
path.user_display().cyan()
|
||||||
)?;
|
)?;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
writeln!(
|
writeln!(
|
||||||
printer.stdout(),
|
printer.stdout(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue