-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
172 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::fmt::Write; | ||
|
||
use anyhow::Result; | ||
|
||
use uv_configuration::PreviewMode; | ||
use uv_tool::InstalledTools; | ||
use uv_warnings::warn_user_once; | ||
|
||
use crate::commands::ExitStatus; | ||
use crate::printer::Printer; | ||
|
||
/// List installed tools. | ||
#[allow(clippy::too_many_arguments)] | ||
pub(crate) async fn list(preview: PreviewMode, printer: Printer) -> Result<ExitStatus> { | ||
if preview.is_disabled() { | ||
warn_user_once!("`uv tool list` is experimental and may change without warning."); | ||
} | ||
|
||
let installed_tools = InstalledTools::from_settings()?; | ||
|
||
let mut tools = installed_tools.tools()?.into_iter().collect::<Vec<_>>(); | ||
tools.sort_by_key(|(name, _)| name.clone()); | ||
|
||
if tools.is_empty() { | ||
writeln!(printer.stderr(), "No tools installed")?; | ||
return Ok(ExitStatus::Success); | ||
} | ||
|
||
// TODO(zanieb): Track and display additional metadata, like entry points | ||
for (name, _tool) in tools { | ||
writeln!(printer.stdout(), "{name}")?; | ||
} | ||
|
||
Ok(ExitStatus::Success) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub(crate) mod install; | ||
pub(crate) mod list; | ||
pub(crate) mod run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#![cfg(all(feature = "python", feature = "pypi"))] | ||
|
||
use assert_cmd::assert::OutputAssertExt; | ||
use assert_fs::fixture::PathChild; | ||
use common::{uv_snapshot, TestContext}; | ||
|
||
mod common; | ||
|
||
#[test] | ||
fn tool_list() { | ||
let context = TestContext::new("3.12"); | ||
let tool_dir = context.temp_dir.child("tools"); | ||
let bin_dir = context.temp_dir.child("bin"); | ||
|
||
// Install `black` | ||
context | ||
.tool_install() | ||
.arg("black==24.2.0") | ||
.env("UV_TOOL_DIR", tool_dir.as_os_str()) | ||
.env("XDG_BIN_HOME", bin_dir.as_os_str()) | ||
.assert() | ||
.success(); | ||
|
||
uv_snapshot!(context.filters(), context.tool_list() | ||
.env("UV_TOOL_DIR", tool_dir.as_os_str()) | ||
.env("XDG_BIN_HOME", bin_dir.as_os_str()), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
black | ||
----- stderr ----- | ||
warning: `uv tool list` is experimental and may change without warning. | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn tool_list_empty() { | ||
let context = TestContext::new("3.12"); | ||
let tool_dir = context.temp_dir.child("tools"); | ||
let bin_dir = context.temp_dir.child("bin"); | ||
|
||
uv_snapshot!(context.filters(), context.tool_list() | ||
.env("UV_TOOL_DIR", tool_dir.as_os_str()) | ||
.env("XDG_BIN_HOME", bin_dir.as_os_str()), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
----- stderr ----- | ||
warning: `uv tool list` is experimental and may change without warning. | ||
No tools installed | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn tool_list_missing_receipt() { | ||
let context = TestContext::new("3.12"); | ||
let tool_dir = context.temp_dir.child("tools"); | ||
let bin_dir = context.temp_dir.child("bin"); | ||
|
||
// Install `black` | ||
context | ||
.tool_install() | ||
.arg("black==24.2.0") | ||
.env("UV_TOOL_DIR", tool_dir.as_os_str()) | ||
.env("XDG_BIN_HOME", bin_dir.as_os_str()) | ||
.assert() | ||
.success(); | ||
|
||
fs_err::remove_file(tool_dir.join("black").join("uv-receipt.toml")).unwrap(); | ||
|
||
uv_snapshot!(context.filters(), context.tool_list() | ||
.env("UV_TOOL_DIR", tool_dir.as_os_str()) | ||
.env("XDG_BIN_HOME", bin_dir.as_os_str()), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
----- stderr ----- | ||
warning: `uv tool list` is experimental and may change without warning. | ||
warning: Ignoring malformed tool `black`: missing receipt at [TEMP_DIR]/tools/black/uv-receipt.toml | ||
No tools installed | ||
"###); | ||
} |