Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add news_url in config.rs #1071

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions man/paru.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ are built or a package in the build queue is needed as a dependency to build
another package, install all the packages in the install queue.

.TP
.B NewsOnUpgrade
Print new news during sysupgrade.
.B NewsOnUpgrade [= URL]
Print new news during sysupgrade. By default paru fetches news from the Arch Linux
RSS news feed. Users of other distributions can customize the RSS feed URL here.

.TP
.B UseAsk
Expand Down
8 changes: 7 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ pub struct Config {
pub aur_rpc_url: Option<Url>,
#[default(Url::parse("https://archlinux.org").unwrap())]
pub arch_url: Url,
pub news_url: Option<Url>,
pub build_dir: PathBuf,
pub cache_dir: PathBuf,
pub state_dir: PathBuf,
Expand Down Expand Up @@ -1056,7 +1057,12 @@ impl Config {
"BatchInstall" => self.batch_install = true,
"UseAsk" => self.use_ask = true,
"SaveChanges" => self.save_changes = true,
"NewsOnUpgrade" => self.news_on_upgrade = true,
uetcis marked this conversation as resolved.
Show resolved Hide resolved
"NewsOnUpgrade" => {
self.news_on_upgrade = true;
if let Some(l) = value {
self.news_url = Some(l.parse()?);
}
}
"InstallDebug" => self.install_debug = true,
"Redownload" => self.redownload = YesNoAll::Yes.default_or(key, value)?,
"Rebuild" => self.rebuild = YesNoAllTree::Yes.default_or(key, value)?,
Expand Down
5 changes: 4 additions & 1 deletion src/news.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ pub fn newest_pkg(config: &Config) -> i64 {
}

pub async fn news(config: &Config) -> Result<i32> {
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?;
Expand Down
Loading