mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 20:31:12 +00:00
Accept --no-upgrade, --no-refresh, etc. on the CLI (#3328)
## Summary We added `--no-X` variants for all other flags, but omitted these. Seems more consistent to support them. Closes https://github.com/astral-sh/uv/issues/1900.
This commit is contained in:
parent
614c07329b
commit
c6137702a5
4 changed files with 75 additions and 35 deletions
|
|
@ -17,13 +17,17 @@ pub enum Reinstall {
|
|||
|
||||
impl Reinstall {
|
||||
/// Determine the reinstall strategy to use.
|
||||
pub fn from_args(reinstall: bool, reinstall_package: Vec<PackageName>) -> Self {
|
||||
if reinstall {
|
||||
Self::All
|
||||
} else if !reinstall_package.is_empty() {
|
||||
Self::Packages(reinstall_package)
|
||||
} else {
|
||||
Self::None
|
||||
pub fn from_args(reinstall: Option<bool>, reinstall_package: Vec<PackageName>) -> Self {
|
||||
match reinstall {
|
||||
Some(true) => Self::All,
|
||||
Some(false) => Self::None,
|
||||
None => {
|
||||
if reinstall_package.is_empty() {
|
||||
Self::None
|
||||
} else {
|
||||
Self::Packages(reinstall_package)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,13 +57,17 @@ pub enum Upgrade {
|
|||
|
||||
impl Upgrade {
|
||||
/// Determine the upgrade strategy from the command-line arguments.
|
||||
pub fn from_args(upgrade: bool, upgrade_package: Vec<PackageName>) -> Self {
|
||||
if upgrade {
|
||||
Self::All
|
||||
} else if !upgrade_package.is_empty() {
|
||||
Self::Packages(upgrade_package.into_iter().collect())
|
||||
} else {
|
||||
Self::None
|
||||
pub fn from_args(upgrade: Option<bool>, upgrade_package: Vec<PackageName>) -> Self {
|
||||
match upgrade {
|
||||
Some(true) => Self::All,
|
||||
Some(false) => Self::None,
|
||||
None => {
|
||||
if upgrade_package.is_empty() {
|
||||
Self::None
|
||||
} else {
|
||||
Self::Packages(upgrade_package.into_iter().collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue