mirror of https://github.com/astral-sh/uv
feat(pip-install): add `--dry-run` flag
This commit is contained in:
parent
8ef396e849
commit
4aae07e914
|
|
@ -64,6 +64,7 @@ pub(crate) async fn pip_install(
|
|||
exclude_newer: Option<DateTime<Utc>>,
|
||||
cache: Cache,
|
||||
mut printer: Printer,
|
||||
dry_run: bool,
|
||||
) -> Result<ExitStatus> {
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
|
|
@ -237,6 +238,14 @@ pub(crate) async fn pip_install(
|
|||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
|
||||
if dry_run {
|
||||
println!("Would have installed:");
|
||||
for package in resolution.packages() {
|
||||
println!(" {}", package);
|
||||
}
|
||||
return Ok(ExitStatus::Success);
|
||||
}
|
||||
|
||||
// Re-initialize the in-flight map.
|
||||
let in_flight = InFlight::default();
|
||||
|
||||
|
|
|
|||
|
|
@ -591,6 +591,11 @@ struct PipInstallArgs {
|
|||
/// format (e.g., `2006-12-02`).
|
||||
#[arg(long, value_parser = date_or_datetime, hide = true)]
|
||||
exclude_newer: Option<DateTime<Utc>>,
|
||||
|
||||
/// Perform a dry run, i.e., don't actually install anything but resolve the dependencies and
|
||||
/// print the resulting plan.
|
||||
#[clap(long)]
|
||||
dry_run: bool,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
|
@ -979,6 +984,7 @@ async fn run() -> Result<ExitStatus> {
|
|||
args.exclude_newer,
|
||||
cache,
|
||||
printer,
|
||||
args.dry_run,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue