From dc637d0b7b534dd4b4be4dbed9f53f0aeac58480 Mon Sep 17 00:00:00 2001 From: Mathieu Kniewallner Date: Wed, 22 Jan 2025 04:10:19 +0100 Subject: [PATCH] fix(cli): conflict `--locked` with `--upgrade` (#10836) ## Summary Relates to #10273. This doesn't solve what is highlighted in https://github.com/astral-sh/uv/issues/10273#issuecomment-2569515066, but I believe this is still an improvement for users not setting `upgrade = true` in `[tool.uv]`. ## Test Plan Ran commands locally: ```shell $ cargo run --quiet -- lock --locked --upgrade error: the argument '--check' cannot be used with '--upgrade' Usage: uv lock --check For more information, try '--help'. ``` --- crates/uv-cli/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 167c920e3..c10404456 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -2835,7 +2835,7 @@ pub struct RunArgs { /// /// Requires that the lockfile is up-to-date. If the lockfile is missing or /// needs to be updated, uv will exit with an error. - #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")] + #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])] pub locked: bool, /// Run without updating the `uv.lock` file. @@ -3058,7 +3058,7 @@ pub struct SyncArgs { /// /// Requires that the lockfile is up-to-date. If the lockfile is missing or /// needs to be updated, uv will exit with an error. - #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")] + #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])] pub locked: bool, /// Sync without updating the `uv.lock` file. @@ -3130,7 +3130,7 @@ pub struct LockArgs { /// missing or needs to be updated, uv will exit with an error. /// /// Equivalent to `--locked`. - #[arg(long, alias = "locked", env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "check_exists")] + #[arg(long, alias = "locked", env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check_exists", "upgrade"])] pub check: bool, /// Assert that a `uv.lock` exists without checking if it is up-to-date. @@ -3265,7 +3265,7 @@ pub struct AddArgs { /// /// Requires that the lockfile is up-to-date. If the lockfile is missing or /// needs to be updated, uv will exit with an error. - #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")] + #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])] pub locked: bool, /// Add dependencies without re-locking the project. @@ -3346,7 +3346,7 @@ pub struct RemoveArgs { /// /// Requires that the lockfile is up-to-date. If the lockfile is missing or /// needs to be updated, uv will exit with an error. - #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")] + #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])] pub locked: bool, /// Remove dependencies without re-locking the project. @@ -3465,7 +3465,7 @@ pub struct TreeArgs { /// /// Requires that the lockfile is up-to-date. If the lockfile is missing or /// needs to be updated, uv will exit with an error. - #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")] + #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])] pub locked: bool, /// Display the requirements without locking the project. @@ -3682,7 +3682,7 @@ pub struct ExportArgs { /// /// Requires that the lockfile is up-to-date. If the lockfile is missing or /// needs to be updated, uv will exit with an error. - #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")] + #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])] pub locked: bool, /// Do not update the `uv.lock` before exporting.