mirror of https://github.com/astral-sh/uv
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
|
|
@ -898,13 +898,17 @@ pub enum Refresh {
|
||||||
|
|
||||||
impl Refresh {
|
impl Refresh {
|
||||||
/// Determine the refresh strategy to use based on the command-line arguments.
|
/// Determine the refresh strategy to use based on the command-line arguments.
|
||||||
pub fn from_args(refresh: bool, refresh_package: Vec<PackageName>) -> Self {
|
pub fn from_args(refresh: Option<bool>, refresh_package: Vec<PackageName>) -> Self {
|
||||||
if refresh {
|
match refresh {
|
||||||
Self::All(Timestamp::now())
|
Some(true) => Self::All(Timestamp::now()),
|
||||||
} else if !refresh_package.is_empty() {
|
Some(false) => Self::None,
|
||||||
Self::Packages(refresh_package, Timestamp::now())
|
None => {
|
||||||
} else {
|
if refresh_package.is_empty() {
|
||||||
Self::None
|
Self::None
|
||||||
|
} else {
|
||||||
|
Self::Packages(refresh_package, Timestamp::now())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,17 @@ pub enum Reinstall {
|
||||||
|
|
||||||
impl Reinstall {
|
impl Reinstall {
|
||||||
/// Determine the reinstall strategy to use.
|
/// Determine the reinstall strategy to use.
|
||||||
pub fn from_args(reinstall: bool, reinstall_package: Vec<PackageName>) -> Self {
|
pub fn from_args(reinstall: Option<bool>, reinstall_package: Vec<PackageName>) -> Self {
|
||||||
if reinstall {
|
match reinstall {
|
||||||
Self::All
|
Some(true) => Self::All,
|
||||||
} else if !reinstall_package.is_empty() {
|
Some(false) => Self::None,
|
||||||
Self::Packages(reinstall_package)
|
None => {
|
||||||
} else {
|
if reinstall_package.is_empty() {
|
||||||
Self::None
|
Self::None
|
||||||
|
} else {
|
||||||
|
Self::Packages(reinstall_package)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,13 +57,17 @@ pub enum Upgrade {
|
||||||
|
|
||||||
impl Upgrade {
|
impl Upgrade {
|
||||||
/// Determine the upgrade strategy from the command-line arguments.
|
/// Determine the upgrade strategy from the command-line arguments.
|
||||||
pub fn from_args(upgrade: bool, upgrade_package: Vec<PackageName>) -> Self {
|
pub fn from_args(upgrade: Option<bool>, upgrade_package: Vec<PackageName>) -> Self {
|
||||||
if upgrade {
|
match upgrade {
|
||||||
Self::All
|
Some(true) => Self::All,
|
||||||
} else if !upgrade_package.is_empty() {
|
Some(false) => Self::None,
|
||||||
Self::Packages(upgrade_package.into_iter().collect())
|
None => {
|
||||||
} else {
|
if upgrade_package.is_empty() {
|
||||||
Self::None
|
Self::None
|
||||||
|
} else {
|
||||||
|
Self::Packages(upgrade_package.into_iter().collect())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -370,9 +370,12 @@ pub(crate) struct PipCompileArgs {
|
||||||
pub(crate) no_offline: bool,
|
pub(crate) no_offline: bool,
|
||||||
|
|
||||||
/// Refresh all cached data.
|
/// Refresh all cached data.
|
||||||
#[arg(long)]
|
#[arg(long, overrides_with("no_refresh"))]
|
||||||
pub(crate) refresh: bool,
|
pub(crate) refresh: bool,
|
||||||
|
|
||||||
|
#[arg(long, overrides_with("refresh"), hide = true)]
|
||||||
|
pub(crate) no_refresh: bool,
|
||||||
|
|
||||||
/// Refresh cached data for a specific package.
|
/// Refresh cached data for a specific package.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub(crate) refresh_package: Vec<PackageName>,
|
pub(crate) refresh_package: Vec<PackageName>,
|
||||||
|
|
@ -474,9 +477,12 @@ pub(crate) struct PipCompileArgs {
|
||||||
pub(crate) no_system: bool,
|
pub(crate) no_system: bool,
|
||||||
|
|
||||||
/// Allow package upgrades, ignoring pinned versions in the existing output file.
|
/// Allow package upgrades, ignoring pinned versions in the existing output file.
|
||||||
#[arg(long, short = 'U')]
|
#[arg(long, short = 'U', overrides_with("no_upgrade"))]
|
||||||
pub(crate) upgrade: bool,
|
pub(crate) upgrade: bool,
|
||||||
|
|
||||||
|
#[arg(long, overrides_with("upgrade"), hide = true)]
|
||||||
|
pub(crate) no_upgrade: bool,
|
||||||
|
|
||||||
/// Allow upgrades for a specific package, ignoring pinned versions in the existing output
|
/// Allow upgrades for a specific package, ignoring pinned versions in the existing output
|
||||||
/// file.
|
/// file.
|
||||||
#[arg(long, short = 'P')]
|
#[arg(long, short = 'P')]
|
||||||
|
|
@ -624,9 +630,12 @@ pub(crate) struct PipSyncArgs {
|
||||||
pub(crate) src_file: Vec<PathBuf>,
|
pub(crate) src_file: Vec<PathBuf>,
|
||||||
|
|
||||||
/// Reinstall all packages, regardless of whether they're already installed.
|
/// Reinstall all packages, regardless of whether they're already installed.
|
||||||
#[arg(long, alias = "force-reinstall")]
|
#[arg(long, alias = "force-reinstall", overrides_with("no_reinstall"))]
|
||||||
pub(crate) reinstall: bool,
|
pub(crate) reinstall: bool,
|
||||||
|
|
||||||
|
#[arg(long, overrides_with("reinstall"), hide = true)]
|
||||||
|
pub(crate) no_reinstall: bool,
|
||||||
|
|
||||||
/// Reinstall a specific package, regardless of whether it's already installed.
|
/// Reinstall a specific package, regardless of whether it's already installed.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub(crate) reinstall_package: Vec<PackageName>,
|
pub(crate) reinstall_package: Vec<PackageName>,
|
||||||
|
|
@ -644,9 +653,12 @@ pub(crate) struct PipSyncArgs {
|
||||||
pub(crate) no_offline: bool,
|
pub(crate) no_offline: bool,
|
||||||
|
|
||||||
/// Refresh all cached data.
|
/// Refresh all cached data.
|
||||||
#[arg(long)]
|
#[arg(long, overrides_with("no_refresh"))]
|
||||||
pub(crate) refresh: bool,
|
pub(crate) refresh: bool,
|
||||||
|
|
||||||
|
#[arg(long, overrides_with("refresh"), hide = true)]
|
||||||
|
pub(crate) no_refresh: bool,
|
||||||
|
|
||||||
/// Refresh cached data for a specific package.
|
/// Refresh cached data for a specific package.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub(crate) refresh_package: Vec<PackageName>,
|
pub(crate) refresh_package: Vec<PackageName>,
|
||||||
|
|
@ -971,17 +983,23 @@ pub(crate) struct PipInstallArgs {
|
||||||
pub(crate) no_all_extras: bool,
|
pub(crate) no_all_extras: bool,
|
||||||
|
|
||||||
/// Allow package upgrades.
|
/// Allow package upgrades.
|
||||||
#[arg(long, short = 'U')]
|
#[arg(long, short = 'U', overrides_with("no_upgrade"))]
|
||||||
pub(crate) upgrade: bool,
|
pub(crate) upgrade: bool,
|
||||||
|
|
||||||
|
#[arg(long, overrides_with("upgrade"), hide = true)]
|
||||||
|
pub(crate) no_upgrade: bool,
|
||||||
|
|
||||||
/// Allow upgrade of a specific package.
|
/// Allow upgrade of a specific package.
|
||||||
#[arg(long, short = 'P')]
|
#[arg(long, short = 'P')]
|
||||||
pub(crate) upgrade_package: Vec<PackageName>,
|
pub(crate) upgrade_package: Vec<PackageName>,
|
||||||
|
|
||||||
/// Reinstall all packages, regardless of whether they're already installed.
|
/// Reinstall all packages, regardless of whether they're already installed.
|
||||||
#[arg(long, alias = "force-reinstall")]
|
#[arg(long, alias = "force-reinstall", overrides_with("no_reinstall"))]
|
||||||
pub(crate) reinstall: bool,
|
pub(crate) reinstall: bool,
|
||||||
|
|
||||||
|
#[arg(long, overrides_with("reinstall"), hide = true)]
|
||||||
|
pub(crate) no_reinstall: bool,
|
||||||
|
|
||||||
/// Reinstall a specific package, regardless of whether it's already installed.
|
/// Reinstall a specific package, regardless of whether it's already installed.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub(crate) reinstall_package: Vec<PackageName>,
|
pub(crate) reinstall_package: Vec<PackageName>,
|
||||||
|
|
@ -999,9 +1017,12 @@ pub(crate) struct PipInstallArgs {
|
||||||
pub(crate) no_offline: bool,
|
pub(crate) no_offline: bool,
|
||||||
|
|
||||||
/// Refresh all cached data.
|
/// Refresh all cached data.
|
||||||
#[arg(long)]
|
#[arg(long, overrides_with("no_refresh"))]
|
||||||
pub(crate) refresh: bool,
|
pub(crate) refresh: bool,
|
||||||
|
|
||||||
|
#[arg(long, overrides_with("refresh"), hide = true)]
|
||||||
|
pub(crate) no_refresh: bool,
|
||||||
|
|
||||||
/// Refresh cached data for a specific package.
|
/// Refresh cached data for a specific package.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub(crate) refresh_package: Vec<PackageName>,
|
pub(crate) refresh_package: Vec<PackageName>,
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@ impl PipCompileSettings {
|
||||||
offline,
|
offline,
|
||||||
no_offline,
|
no_offline,
|
||||||
refresh,
|
refresh,
|
||||||
|
no_refresh,
|
||||||
refresh_package,
|
refresh_package,
|
||||||
link_mode,
|
link_mode,
|
||||||
index_url,
|
index_url,
|
||||||
|
|
@ -171,6 +172,7 @@ impl PipCompileSettings {
|
||||||
system,
|
system,
|
||||||
no_system,
|
no_system,
|
||||||
upgrade,
|
upgrade,
|
||||||
|
no_upgrade,
|
||||||
upgrade_package,
|
upgrade_package,
|
||||||
generate_hashes,
|
generate_hashes,
|
||||||
no_generate_hashes,
|
no_generate_hashes,
|
||||||
|
|
@ -207,8 +209,8 @@ impl PipCompileSettings {
|
||||||
.filter_map(Maybe::into_option)
|
.filter_map(Maybe::into_option)
|
||||||
.collect(),
|
.collect(),
|
||||||
r#override,
|
r#override,
|
||||||
refresh: Refresh::from_args(refresh, refresh_package),
|
refresh: Refresh::from_args(flag(refresh, no_refresh), refresh_package),
|
||||||
upgrade: Upgrade::from_args(upgrade, upgrade_package),
|
upgrade: Upgrade::from_args(flag(upgrade, no_upgrade), upgrade_package),
|
||||||
uv_lock: flag(unstable_uv_lock_file, no_unstable_uv_lock_file).unwrap_or(false),
|
uv_lock: flag(unstable_uv_lock_file, no_unstable_uv_lock_file).unwrap_or(false),
|
||||||
|
|
||||||
// Shared settings.
|
// Shared settings.
|
||||||
|
|
@ -287,10 +289,12 @@ impl PipSyncSettings {
|
||||||
let PipSyncArgs {
|
let PipSyncArgs {
|
||||||
src_file,
|
src_file,
|
||||||
reinstall,
|
reinstall,
|
||||||
|
no_reinstall,
|
||||||
reinstall_package,
|
reinstall_package,
|
||||||
offline,
|
offline,
|
||||||
refresh,
|
refresh,
|
||||||
no_offline,
|
no_offline,
|
||||||
|
no_refresh,
|
||||||
refresh_package,
|
refresh_package,
|
||||||
link_mode,
|
link_mode,
|
||||||
index_url,
|
index_url,
|
||||||
|
|
@ -328,8 +332,8 @@ impl PipSyncSettings {
|
||||||
Self {
|
Self {
|
||||||
// CLI-only settings.
|
// CLI-only settings.
|
||||||
src_file,
|
src_file,
|
||||||
reinstall: Reinstall::from_args(reinstall, reinstall_package),
|
reinstall: Reinstall::from_args(flag(reinstall, no_reinstall), reinstall_package),
|
||||||
refresh: Refresh::from_args(refresh, refresh_package),
|
refresh: Refresh::from_args(flag(refresh, no_refresh), refresh_package),
|
||||||
|
|
||||||
// Shared settings.
|
// Shared settings.
|
||||||
shared: PipSharedSettings::combine(
|
shared: PipSharedSettings::combine(
|
||||||
|
|
@ -403,12 +407,15 @@ impl PipInstallSettings {
|
||||||
all_extras,
|
all_extras,
|
||||||
no_all_extras,
|
no_all_extras,
|
||||||
upgrade,
|
upgrade,
|
||||||
|
no_upgrade,
|
||||||
upgrade_package,
|
upgrade_package,
|
||||||
reinstall,
|
reinstall,
|
||||||
|
no_reinstall,
|
||||||
reinstall_package,
|
reinstall_package,
|
||||||
offline,
|
offline,
|
||||||
refresh,
|
refresh,
|
||||||
no_offline,
|
no_offline,
|
||||||
|
no_refresh,
|
||||||
refresh_package,
|
refresh_package,
|
||||||
no_deps,
|
no_deps,
|
||||||
deps,
|
deps,
|
||||||
|
|
@ -459,9 +466,9 @@ impl PipInstallSettings {
|
||||||
.filter_map(Maybe::into_option)
|
.filter_map(Maybe::into_option)
|
||||||
.collect(),
|
.collect(),
|
||||||
r#override,
|
r#override,
|
||||||
upgrade: Upgrade::from_args(upgrade, upgrade_package),
|
upgrade: Upgrade::from_args(flag(upgrade, no_upgrade), upgrade_package),
|
||||||
reinstall: Reinstall::from_args(reinstall, reinstall_package),
|
reinstall: Reinstall::from_args(flag(reinstall, no_reinstall), reinstall_package),
|
||||||
refresh: Refresh::from_args(refresh, refresh_package),
|
refresh: Refresh::from_args(flag(refresh, no_refresh), refresh_package),
|
||||||
dry_run,
|
dry_run,
|
||||||
|
|
||||||
// Shared settings.
|
// Shared settings.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue