Add a flag to disable showing Arch Linux news (fix #786)

This commit is contained in:
Roey Darwish Dror
2021-10-29 09:53:30 +03:00
parent f235c56b82
commit 0467bd4dde
3 changed files with 19 additions and 5 deletions

View File

@@ -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"

View File

@@ -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>,
@@ -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 {

View File

@@ -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);