Allow uv add to specify optional dependency groups (#4607)

## Summary

Implements `uv add --optional <group>`, which adds a dependency to
`project.optional-dependency.<group>`.

Resolves https://github.com/astral-sh/uv/issues/4585.
This commit is contained in:
Ibraheem Ahmed 2024-06-27 21:24:21 -04:00 committed by GitHub
parent 9b38450998
commit bbd59ff455
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 443 additions and 113 deletions

View file

@ -1763,9 +1763,13 @@ pub struct AddArgs {
pub requirements: Vec<String>,
/// Add the requirements as development dependencies.
#[arg(long)]
#[arg(long, conflicts_with("optional"))]
pub dev: bool,
/// Add the requirements to the specified optional dependency group.
#[arg(long, conflicts_with("dev"))]
pub optional: Option<ExtraName>,
/// Add the requirements as editables.
#[arg(long, default_missing_value = "true", num_args(0..=1))]
pub editable: Option<bool>,
@ -1829,9 +1833,13 @@ pub struct RemoveArgs {
pub requirements: Vec<PackageName>,
/// Remove the requirements from development dependencies.
#[arg(long)]
#[arg(long, conflicts_with("optional"))]
pub dev: bool,
/// Remove the requirements from the specified optional dependency group.
#[arg(long, conflicts_with("dev"))]
pub optional: Option<ExtraName>,
/// Remove the dependency from a specific package in the workspace.
#[arg(long, conflicts_with = "isolated")]
pub package: Option<PackageName>,