Skip to content

Commit 3fed672

Browse files
committed
feat: use --no-default-groups instead of --no-groups
1 parent e086c06 commit 3fed672

File tree

5 files changed

+184
-46
lines changed

5 files changed

+184
-46
lines changed

crates/uv-cli/src/lib.rs

+20-12
Original file line numberDiff line numberDiff line change
@@ -2707,9 +2707,11 @@ pub struct RunArgs {
27072707
#[arg(long)]
27082708
pub no_group: Vec<GroupName>,
27092709

2710-
/// Exclude dependencies from all dependency groups.
2711-
#[arg(long, conflicts_with_all = ["group", "no_group", "only_group"])]
2712-
pub no_groups: bool,
2710+
/// Exclude dependencies from default groups.
2711+
///
2712+
/// `--group` can be used to include specific groups.
2713+
#[arg(long, conflicts_with_all = ["no_group", "only_group"])]
2714+
pub no_default_groups: bool,
27132715

27142716
/// Only include dependencies from the specified dependency group.
27152717
///
@@ -2976,9 +2978,11 @@ pub struct SyncArgs {
29762978
#[arg(long)]
29772979
pub no_group: Vec<GroupName>,
29782980

2979-
/// Exclude dependencies from all dependency groups.
2980-
#[arg(long, conflicts_with_all = ["group", "no_group", "only_group"])]
2981-
pub no_groups: bool,
2981+
/// Exclude dependencies from default groups.
2982+
///
2983+
/// `--group` can be used to include specific groups.
2984+
#[arg(long, conflicts_with_all = ["no_group", "only_group"])]
2985+
pub no_default_groups: bool,
29822986

29832987
/// Only include dependencies from the specified dependency group.
29842988
///
@@ -3425,9 +3429,11 @@ pub struct TreeArgs {
34253429
#[arg(long)]
34263430
pub no_group: Vec<GroupName>,
34273431

3428-
/// Exclude dependencies from all dependency groups.
3429-
#[arg(long, conflicts_with_all = ["group", "no_group", "only_group"])]
3430-
pub no_groups: bool,
3432+
/// Exclude dependencies from default groups.
3433+
///
3434+
/// `--group` can be used to include specific groups.
3435+
#[arg(long, conflicts_with_all = ["no_group", "only_group"])]
3436+
pub no_default_groups: bool,
34313437

34323438
/// Only include dependencies from the specified dependency group.
34333439
///
@@ -3593,9 +3599,11 @@ pub struct ExportArgs {
35933599
#[arg(long)]
35943600
pub no_group: Vec<GroupName>,
35953601

3596-
/// Exclude dependencies from all dependency groups.
3597-
#[arg(long, conflicts_with_all = ["group", "no_group", "only_group"])]
3598-
pub no_groups: bool,
3602+
/// Exclude dependencies from default groups.
3603+
///
3604+
/// `--group` can be used to include specific groups.
3605+
#[arg(long, conflicts_with_all = ["no_group", "only_group"])]
3606+
pub no_default_groups: bool,
35993607

36003608
/// Only include dependencies from the specified dependency group.
36013609
///

crates/uv-configuration/src/dev.rs

+19-12
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ pub enum GroupsSpecification {
6565
include: IncludeGroups,
6666
exclude: Vec<GroupName>,
6767
},
68+
/// Explicitly include dependencies from the specified groups.
69+
///
70+
/// If the list is empty, no group will be included.
71+
IncludeExplicitly(Vec<GroupName>),
6872
/// Only include dependencies from the specified groups, exclude all other dependencies.
6973
///
7074
/// The `include` list is guaranteed to omit groups in the `exclude` list (i.e., they have an
@@ -73,8 +77,6 @@ pub enum GroupsSpecification {
7377
include: Vec<GroupName>,
7478
exclude: Vec<GroupName>,
7579
},
76-
/// Exclude dependencies from all groups.
77-
Exclude,
7880
}
7981

8082
impl GroupsSpecification {
@@ -88,7 +90,7 @@ impl GroupsSpecification {
8890

8991
/// Returns `true` if the specification allows for production dependencies.
9092
pub fn prod(&self) -> bool {
91-
matches!(self, Self::Include { .. } | Self::Exclude)
93+
matches!(self, Self::Include { .. } | Self::IncludeExplicitly(_))
9294
}
9395

9496
/// Returns `true` if the specification is limited to a select set of groups.
@@ -120,7 +122,11 @@ impl GroupsSpecification {
120122
[group] => Some(Cow::Owned(format!("--only-group {group}"))),
121123
[..] => Some(Cow::Borrowed("--only-group")),
122124
},
123-
Self::Exclude => Some(Cow::Borrowed("--no-groups")),
125+
Self::IncludeExplicitly(include) => match include.as_slice() {
126+
[] => Some(Cow::Borrowed("--no-default-groups")),
127+
[group] => Some(Cow::Owned(format!("--no-group {group}"))),
128+
[..] => Some(Cow::Borrowed("--no-group")),
129+
},
124130
}
125131
}
126132

@@ -133,7 +139,7 @@ impl GroupsSpecification {
133139
GroupsSpecification::Only { include, exclude } => {
134140
Either::Left(include.iter().chain(exclude.iter()))
135141
}
136-
GroupsSpecification::Exclude => Either::Right(std::iter::empty()),
142+
GroupsSpecification::IncludeExplicitly(include) => Either::Right(include.iter()),
137143
}
138144
}
139145

@@ -145,7 +151,7 @@ impl GroupsSpecification {
145151
include.contains(group) && !exclude.contains(group)
146152
}
147153
GroupsSpecification::Only { include, .. } => include.contains(group),
148-
GroupsSpecification::Exclude => false,
154+
GroupsSpecification::IncludeExplicitly(include) => include.contains(group),
149155
}
150156
}
151157
}
@@ -185,7 +191,7 @@ impl DevGroupsSpecification {
185191
only_dev: bool,
186192
mut group: Vec<GroupName>,
187193
no_group: Vec<GroupName>,
188-
no_groups: bool,
194+
no_default_groups: bool,
189195
mut only_group: Vec<GroupName>,
190196
all_groups: bool,
191197
) -> Self {
@@ -199,8 +205,8 @@ impl DevGroupsSpecification {
199205
None
200206
};
201207

202-
let groups = if no_groups {
203-
Some(GroupsSpecification::Exclude)
208+
let groups = if no_default_groups {
209+
Some(GroupsSpecification::IncludeExplicitly(group))
204210
} else if all_groups {
205211
Some(GroupsSpecification::Include {
206212
include: IncludeGroups::All,
@@ -386,9 +392,10 @@ impl DevGroupsManifest {
386392
};
387393
}
388394

389-
// If `--no-groups` was provided, exclude all groups.
390-
if matches!(self.spec.groups(), Some(GroupsSpecification::Exclude)) {
391-
return false;
395+
// If `--no-default-groups` was provided, only include group if it's explicitly
396+
// included with `--group <group>`.
397+
if let Some(GroupsSpecification::IncludeExplicitly(include)) = self.spec.groups() {
398+
return include.contains(group);
392399
}
393400

394401
// If `--no-group` was provided, exclude the group from the list of defaults.

crates/uv/src/settings.rs

+36-8
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl RunSettings {
300300
no_dev,
301301
group,
302302
no_group,
303-
no_groups,
303+
no_default_groups,
304304
only_group,
305305
all_groups,
306306
module: _,
@@ -344,7 +344,14 @@ impl RunSettings {
344344
extra.unwrap_or_default(),
345345
),
346346
dev: DevGroupsSpecification::from_args(
347-
dev, no_dev, only_dev, group, no_group, no_groups, only_group, all_groups,
347+
dev,
348+
no_dev,
349+
only_dev,
350+
group,
351+
no_group,
352+
no_default_groups,
353+
only_group,
354+
all_groups,
348355
),
349356
editable: EditableMode::from_args(no_editable),
350357
modifications: if flag(exact, inexact).unwrap_or(false) {
@@ -961,7 +968,7 @@ impl SyncSettings {
961968
only_dev,
962969
group,
963970
no_group,
964-
no_groups,
971+
no_default_groups,
965972
only_group,
966973
all_groups,
967974
no_editable,
@@ -998,7 +1005,14 @@ impl SyncSettings {
9981005
extra.unwrap_or_default(),
9991006
),
10001007
dev: DevGroupsSpecification::from_args(
1001-
dev, no_dev, only_dev, group, no_group, no_groups, only_group, all_groups,
1008+
dev,
1009+
no_dev,
1010+
only_dev,
1011+
group,
1012+
no_group,
1013+
no_default_groups,
1014+
only_group,
1015+
all_groups,
10021016
),
10031017
editable: EditableMode::from_args(no_editable),
10041018
install_options: InstallOptions::new(
@@ -1318,7 +1332,7 @@ impl TreeSettings {
13181332
no_dev,
13191333
group,
13201334
no_group,
1321-
no_groups,
1335+
no_default_groups,
13221336
only_group,
13231337
all_groups,
13241338
locked,
@@ -1337,7 +1351,14 @@ impl TreeSettings {
13371351

13381352
Self {
13391353
dev: DevGroupsSpecification::from_args(
1340-
dev, no_dev, only_dev, group, no_group, no_groups, only_group, all_groups,
1354+
dev,
1355+
no_dev,
1356+
only_dev,
1357+
group,
1358+
no_group,
1359+
no_default_groups,
1360+
only_group,
1361+
all_groups,
13411362
),
13421363
locked,
13431364
frozen,
@@ -1400,7 +1421,7 @@ impl ExportSettings {
14001421
only_dev,
14011422
group,
14021423
no_group,
1403-
no_groups,
1424+
no_default_groups,
14041425
only_group,
14051426
all_groups,
14061427
header,
@@ -1436,7 +1457,14 @@ impl ExportSettings {
14361457
extra.unwrap_or_default(),
14371458
),
14381459
dev: DevGroupsSpecification::from_args(
1439-
dev, no_dev, only_dev, group, no_group, no_groups, only_group, all_groups,
1460+
dev,
1461+
no_dev,
1462+
only_dev,
1463+
group,
1464+
no_group,
1465+
no_default_groups,
1466+
only_group,
1467+
all_groups,
14401468
),
14411469
editable: EditableMode::from_args(no_editable),
14421470
hashes: flag(hashes, no_hashes).unwrap_or(true),

0 commit comments

Comments
 (0)