-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b896657
commit d46a9e3
Showing
12 changed files
with
188 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use either::Either; | ||
use uv_normalize::GroupName; | ||
|
||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] | ||
pub enum DevMode { | ||
/// Include development dependencies. | ||
#[default] | ||
Include, | ||
/// Exclude development dependencies. | ||
Exclude, | ||
/// Only include development dependencies, excluding all other dependencies. | ||
Only, | ||
} | ||
|
||
impl DevMode { | ||
/// Determine the [`DevMode`] policy from the command-line arguments. | ||
pub fn from_args(dev: bool, no_dev: bool, only_dev: bool) -> Self { | ||
if only_dev { | ||
Self::Only | ||
} else if no_dev { | ||
Self::Exclude | ||
} else if dev { | ||
Self::Include | ||
} else { | ||
Self::default() | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub enum DevSpecification<'group> { | ||
/// Include dev dependencies from the specified group. | ||
Include(&'group [GroupName]), | ||
/// Do not include dev dependencies. | ||
Exclude, | ||
/// Include dev dependencies from the specified group, and exclude all non-dev dependencies. | ||
Only(&'group [GroupName]), | ||
} | ||
|
||
impl<'group> DevSpecification<'group> { | ||
/// Returns an [`Iterator`] over the group names to include. | ||
pub fn iter(&self) -> impl Iterator<Item = &GroupName> { | ||
match self { | ||
Self::Exclude => Either::Left(std::iter::empty()), | ||
Self::Include(groups) | Self::Only(groups) => Either::Right(groups.iter()), | ||
} | ||
} | ||
|
||
/// Returns `true` if the specification allows for production dependencies. | ||
pub fn prod(&self) -> bool { | ||
matches!(self, Self::Exclude | Self::Include(_)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.