Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Add a flag to disable showing Arch Linux news (fix #786)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-darwish committed Oct 29, 2021
1 parent f235c56 commit 0467bd4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#arch_package_manager = "pacman"
# Arguments to pass yay (or paru) when updating packages
#yay_arguments = "--nodevel"
#show_arch_news = true
#trizen_arguments = "--devel"
#enable_tlmgr = true
#emerge_sync_flags = "-q"
Expand Down
11 changes: 11 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ pub enum ArchPackageManager {
pub struct Linux {
yay_arguments: Option<String>,
arch_package_manager: Option<ArchPackageManager>,
show_arch_news: Option<bool>,
trizen_arguments: Option<String>,
dnf_arguments: Option<String>,
apt_arguments: Option<String>,
Expand Down Expand Up @@ -641,6 +642,16 @@ impl Config {
.unwrap_or("")
}

/// Show news on Arch Linux
#[allow(dead_code)]
pub fn show_arch_news(&self) -> bool {
self.config_file
.linux
.as_ref()
.and_then(|s| s.show_arch_news)
.unwrap_or(true)
}

/// Extra yay arguments
#[allow(dead_code)]
pub fn arch_package_manager(&self) -> ArchPackageManager {
Expand Down
12 changes: 7 additions & 5 deletions src/steps/os/archlinux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ pub struct YayParu {

impl ArchPackageManager for YayParu {
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
Command::new(&self.executable)
.arg("-Pw")
.spawn()
.and_then(|mut p| p.wait())
.ok();
if ctx.config().show_arch_news() {
Command::new(&self.executable)
.arg("-Pw")
.spawn()
.and_then(|mut p| p.wait())
.ok();
}

let mut command = ctx.run_type().execute(&self.executable);

Expand Down

0 comments on commit 0467bd4

Please sign in to comment.