diff --git a/completions/bash b/completions/bash index f6b2ba84..7c2cf084 100644 --- a/completions/bash +++ b/completions/bash @@ -69,7 +69,7 @@ _paru() { common=('arch cachedir color config confirm dbpath debug gpgdir help hookdir logfile noconfirm noprogressbar noscriptlet quiet root verbose - repo aur aururl clonedir makepkg mflags pacman pacman-conf git gitflags sudo sudoflags + repo aur aururl newsurl clonedir makepkg mflags pacman pacman-conf git gitflags sudo sudoflags asp gpg gpgflags fm fmflags chrootflags pager completioninterval sortby searchby limit upgrademenu removemake noremovemake cleanafter nocleanafter rebuild rebuildall norebuild rebuildtree redownload noredownload redownloadall pgpfetch nopgpfetch useask diff --git a/completions/fish b/completions/fish index f51eb38f..8b685c63 100644 --- a/completions/fish +++ b/completions/fish @@ -196,6 +196,7 @@ complete -c $progname -n "not $noopt" -l repo -d 'Assume targets are from the re complete -c $progname -n "not $noopt" -s a -l aur -d 'Assume targets are from the AUR' -f complete -c $progname -n "not $noopt" -l aururl -d 'Set an alternative AUR URL' -f complete -c $progname -n "not $noopt" -l aurrpcurl -d 'Set an alternative URL for the AUR /rpc endpoint' -f +complete -c $progname -n "not $noopt" -l newsurl -d 'Set an alternative URL for the news feed' -f complete -c $progname -n "not $noopt" -l clonedir -d 'Directory used to download and run PKGBUILDs' -r complete -c $progname -n "not $noopt" -l makepkg -d 'Makepkg command to use' -f complete -c $progname -n "not $noopt" -l pacman -d 'Pacman command to use' -f diff --git a/completions/zsh b/completions/zsh index 5c9fb840..4985a74d 100644 --- a/completions/zsh +++ b/completions/zsh @@ -50,6 +50,7 @@ _pacman_opts_common=( {-a,--aur}'[Assume targets are from the AUR]' '--aururl[Set an alternative AUR URL]:url' '--aurrpcurl[Set an alternative URL for the AUR /rpc endpoint]:url' + '--newsurl[Set an alternative URL for the news feed]:url' '--clonedir[Directory used to download and run PKGBUILDs]:build dir:_files -/' '--makepkg[makepkg command to use]:makepkg:_files' diff --git a/man/paru.8 b/man/paru.8 index cddaa8ea..728e5d5a 100644 --- a/man/paru.8 +++ b/man/paru.8 @@ -598,6 +598,10 @@ gpg config\%. .B \-\-newsonupgrade Print new news during sysupgrade. +.TP +.B \-\-newsurl +Set an alternative URL for the news feed. Defaults to the Arch Linux news feed. + .TP .B \-\-useask Use pacman's --ask flag to automatically confirm package conflicts. Paru lists diff --git a/man/paru.conf.5 b/man/paru.conf.5 index 9442a311..164d8d4c 100644 --- a/man/paru.conf.5 +++ b/man/paru.conf.5 @@ -138,6 +138,10 @@ another package, install all the packages in the install queue. .B NewsOnUpgrade Print new news during sysupgrade. +.TP +.B NewsUrl = URL +URL of the RSS/Atom feed to fetch news from. Defaults to the Arch Linux news feed. + .TP .B UseAsk Use pacman's --ask flag to automatically confirm package conflicts. Paru lists diff --git a/src/command_line.rs b/src/command_line.rs index 2d87e71e..b5b8bc64 100644 --- a/src/command_line.rs +++ b/src/command_line.rs @@ -302,6 +302,7 @@ impl Config { Arg::Long("print") | Arg::Short('p') => self.print = true, Arg::Long("newsonupgrade") => self.news_on_upgrade = true, Arg::Long("nonewsonupgrade") => self.news_on_upgrade = false, + Arg::Long("newsurl") => self.news_url = Some(value?.parse()?), Arg::Long("comments") => self.comments += 1, Arg::Long("ssh") => self.ssh = true, Arg::Long("failfast") => self.fail_fast = true, @@ -424,6 +425,7 @@ fn takes_value(arg: Arg) -> TakesValue { Arg::Long("redownload") => TakesValue::Optional, Arg::Long("rebuild") => TakesValue::Optional, Arg::Long("sudoloop") => TakesValue::Optional, + Arg::Long("newsurl") => TakesValue::Required, Arg::Long("develsuffixes") => TakesValue::Required, Arg::Long("localrepo") => TakesValue::Optional, Arg::Long("chroot") => TakesValue::Optional, diff --git a/src/config.rs b/src/config.rs index 0ecfcccf..7f91354e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -409,6 +409,7 @@ pub struct Config { pub aur_rpc_url: Option, #[default(Url::parse("https://archlinux.org").unwrap())] pub arch_url: Url, + pub news_url: Option, pub build_dir: PathBuf, pub cache_dir: PathBuf, pub state_dir: PathBuf, @@ -1062,6 +1063,12 @@ then initialise it with: "SaveChanges" => self.save_changes = true, "NewsOnUpgrade" => self.news_on_upgrade = true, "InstallDebug" => self.install_debug = true, + "NewsUrl" => { + self.news_url = Some(value.ok_or_else(|| anyhow!(tr!( + "value can not be empty for key '{}'", + key + )))?.parse()?) + } "Redownload" => self.redownload = YesNoAll::Yes.default_or(key, value)?, "Rebuild" => self.rebuild = YesNoAllTree::Yes.default_or(key, value)?, "RemoveMake" => self.remove_make = YesNoAsk::Yes.default_or(key, value)?, diff --git a/src/help.rs b/src/help.rs index 8287b000..5ced3dbf 100644 --- a/src/help.rs +++ b/src/help.rs @@ -38,6 +38,7 @@ pub fn help() { ); printtr!(" --aururl Set an alternative AUR URL"); printtr!(" --aurrpcur Set an alternative URL for the AUR /rpc endpoint"); + printtr!(" --newsurl Set an alternative URL for the news feed"); printtr!(" --clonedir Directory used to download and run PKGBUILDs"); println!(); printtr!(" --makepkg makepkg command to use"); diff --git a/src/news.rs b/src/news.rs index db9335c4..41f7f1f5 100644 --- a/src/news.rs +++ b/src/news.rs @@ -30,7 +30,10 @@ pub fn newest_pkg(config: &Config) -> i64 { } pub async fn news(config: &Config) -> Result { - let url = config.arch_url.join("feeds/news")?; + let url = config + .news_url + .clone() + .unwrap_or(config.arch_url.join("feeds/news")?); let client = config.raur.client(); let resp = client.get(url.clone()).send().await?; @@ -62,7 +65,12 @@ pub async fn news(config: &Config) -> Result { println!("{}", c.bold.paint(title)); printed = true; - parse_html(config, item.description().unwrap_or_default()); + let content = item + .content() + .filter(|s| !s.is_empty()) + .or(item.description()) + .unwrap_or_default(); + parse_html(config, content); } if !printed {