mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Add --force
option to uv toolchain install
(#4313)
This commit is contained in:
parent
92802df223
commit
b74de31967
4 changed files with 25 additions and 14 deletions
|
@ -2081,8 +2081,12 @@ pub(crate) struct ToolchainListArgs {
|
|||
pub(crate) struct ToolchainInstallArgs {
|
||||
/// The toolchain to install.
|
||||
///
|
||||
/// If not provided, the latest available version will be installed.
|
||||
/// If not provided, the latest available version will be installed unless a toolchain was previously installed.
|
||||
pub(crate) target: Option<String>,
|
||||
|
||||
/// Force the installation of the toolchain, even if it is already installed.
|
||||
#[arg(long, short)]
|
||||
pub(crate) force: bool,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
|
|
@ -16,6 +16,7 @@ use crate::printer::Printer;
|
|||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) async fn install(
|
||||
target: Option<String>,
|
||||
force: bool,
|
||||
native_tls: bool,
|
||||
connectivity: Connectivity,
|
||||
preview: PreviewMode,
|
||||
|
@ -58,19 +59,23 @@ pub(crate) async fn install(
|
|||
toolchain.key()
|
||||
)?;
|
||||
|
||||
if matches!(request, ToolchainRequest::Any) {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"A toolchain is already installed. Use `uv toolchain install <request>` to install a specific toolchain.",
|
||||
)?;
|
||||
if force {
|
||||
writeln!(printer.stderr(), "Forcing reinstallation...")?;
|
||||
} else {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Already installed at {}",
|
||||
toolchain.path().user_display()
|
||||
)?;
|
||||
if matches!(request, ToolchainRequest::Any) {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"A toolchain is already installed. Use `uv toolchain install <request>` to install a specific toolchain.",
|
||||
)?;
|
||||
} else {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Already installed at {}",
|
||||
toolchain.path().user_display()
|
||||
)?;
|
||||
}
|
||||
return Ok(ExitStatus::Success);
|
||||
}
|
||||
return Ok(ExitStatus::Success);
|
||||
}
|
||||
|
||||
// Fill platform information missing from the request
|
||||
|
|
|
@ -740,6 +740,7 @@ async fn run() -> Result<ExitStatus> {
|
|||
|
||||
commands::toolchain_install(
|
||||
args.target,
|
||||
args.force,
|
||||
globals.native_tls,
|
||||
globals.connectivity,
|
||||
globals.preview,
|
||||
|
|
|
@ -249,15 +249,16 @@ impl ToolchainListSettings {
|
|||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ToolchainInstallSettings {
|
||||
pub(crate) target: Option<String>,
|
||||
pub(crate) force: bool,
|
||||
}
|
||||
|
||||
impl ToolchainInstallSettings {
|
||||
/// Resolve the [`ToolchainInstallSettings`] from the CLI and workspace configuration.
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
pub(crate) fn resolve(args: ToolchainInstallArgs, _workspace: Option<Workspace>) -> Self {
|
||||
let ToolchainInstallArgs { target } = args;
|
||||
let ToolchainInstallArgs { target, force } = args;
|
||||
|
||||
Self { target }
|
||||
Self { target, force }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue