Files
uv/crates/uv-dev/src/list_packages.rs
T
konsti bd8503a2cd Introduce a 10s connect timeout (#17733)
See https://github.com/astral-sh/uv/issues/17697 for discussion.

Introduce a 10s connect timeout, configurable with
`UV_HTTP_CONNECT_TIMEOUT`. The existing HTTP timeout gets the more
precise description as HTTP _read_ timeout.
2026-02-05 14:24:41 +01:00

40 lines
1.0 KiB
Rust

use anstream::println;
use anyhow::Result;
use clap::Parser;
use uv_cache::{Cache, CacheArgs};
use uv_client::{BaseClientBuilder, RegistryClientBuilder};
use uv_distribution_types::IndexUrl;
use uv_settings::EnvironmentOptions;
#[derive(Parser)]
pub(crate) struct ListPackagesArgs {
/// The Simple API index URL (e.g., <https://pypi.org/simple>/)
url: String,
#[command(flatten)]
cache_args: CacheArgs,
}
pub(crate) async fn list_packages(
args: ListPackagesArgs,
environment: EnvironmentOptions,
) -> Result<()> {
let cache = Cache::try_from(args.cache_args)?.init().await?;
let client = RegistryClientBuilder::new(
BaseClientBuilder::default()
.read_timeout(environment.http_read_timeout)
.connect_timeout(environment.http_connect_timeout),
cache,
)
.build();
let index_url = IndexUrl::parse(&args.url, None)?;
let index = client.fetch_simple_index(&index_url).await?;
for package_name in index.iter() {
println!("{}", package_name);
}
Ok(())
}