feat(brew): adds "greedy-latest" option to Brew (#636)

This commit is contained in:
luciodaou
2024-02-17 00:45:57 -03:00
committed by GitHub
parent 7a3f3a8905
commit 8991bc9f62
3 changed files with 14 additions and 0 deletions

View File

@@ -104,6 +104,7 @@
[brew] [brew]
# greedy_cask = true # greedy_cask = true
# greedy_latest = true
# autoremove = true # autoremove = true
# Upgrade formulae built from the HEAD branch; `brew upgrade --fetch-HEAD` # Upgrade formulae built from the HEAD branch; `brew upgrade --fetch-HEAD`

View File

@@ -254,6 +254,7 @@ pub struct Flatpak {
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Brew { pub struct Brew {
greedy_cask: Option<bool>, greedy_cask: Option<bool>,
greedy_latest: Option<bool>,
autoremove: Option<bool>, autoremove: Option<bool>,
fetch_head: Option<bool>, fetch_head: Option<bool>,
} }
@@ -1089,6 +1090,15 @@ impl Config {
.unwrap_or(false) .unwrap_or(false)
} }
/// Whether Brew cask should be greedy_latest
pub fn brew_greedy_latest(&self) -> bool {
self.config_file
.brew
.as_ref()
.and_then(|c| c.greedy_latest)
.unwrap_or(false)
}
/// Whether Brew should autoremove /// Whether Brew should autoremove
pub fn brew_autoremove(&self) -> bool { pub fn brew_autoremove(&self) -> bool {
self.config_file self.config_file

View File

@@ -333,6 +333,9 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()>
if ctx.config().brew_cask_greedy() { if ctx.config().brew_cask_greedy() {
brew_args.push("--greedy"); brew_args.push("--greedy");
} }
if ctx.config().brew_greedy_latest() {
brew_args.push("--greedy-latest");
}
} }
variant.execute(run_type).args(&brew_args).status_checked()?; variant.execute(run_type).args(&brew_args).status_checked()?;