Skip to content

Commit

Permalink
Support getting all comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Nov 15, 2024
1 parent e2277b4 commit 211f78b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions man/paru.8
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ Prints the PKGBUILD to the terminal instead of downloading it.
.B \-c, \-\-comments
Print the AUR comments from the PKGBUILD's AUR page.

Pass twice to get all comments instead of the first page.

.TP
.B \-s, \-\-ssh
Clone the AUR package using SSH (e.g.: a read-write remote).
Expand Down
4 changes: 2 additions & 2 deletions src/command_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl Config {
Arg::Short('c') => {
self.complete = true;
self.clean += 1;
self.comments = true;
self.comments += 1;
}
Arg::Long("install") | Arg::Short('i') => self.install = true,
Arg::Long("sysupgrade") | Arg::Short('u') => self.sysupgrade = true,
Expand All @@ -299,7 +299,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("comments") => self.comments = true,
Arg::Long("comments") => self.comments += 1,
Arg::Long("ssh") => self.ssh = true,
Arg::Long("failfast") => self.fail_fast = true,
Arg::Long("nofailfast") => self.fail_fast = false,
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ pub struct Config {
pub complete: bool,
pub print: bool,
pub news_on_upgrade: bool,
pub comments: bool,
pub comments: usize,
pub ssh: bool,
pub keep_repo_cache: bool,
pub fail_fast: bool,
Expand Down
6 changes: 5 additions & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,14 @@ pub async fn show_comments(config: &mut Config) -> Result<i32> {
let c = config.color;

for base in &bases.bases {
let url = config
let mut url = config
.aur_url
.join(&format!("packages/{}", base.package_base()))?;

if config.comments >= 2 {
url.set_query(Some("PP=250"));
}

let response = client
.get(url.clone())
.send()
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ async fn handle_show(config: &mut Config) -> Result<i32> {
async fn handle_get_pkg_build(config: &mut Config) -> Result<i32> {
if config.print {
download::show_pkgbuilds(config).await
} else if config.comments {
} else if config.comments >= 1 {
download::show_comments(config).await
} else {
download::getpkgbuilds(config).await
Expand Down

0 comments on commit 211f78b

Please sign in to comment.