forked from bencahill/binfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aurcomm
executable file
·45 lines (36 loc) · 1.15 KB
/
aurcomm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
#
# retreive aur comments for a package
# - package name can be specified or pulled from a PKGBUILD in $PWD
# - specify -a to show all comments
#
AURURL="http://aur.archlinux.org"
ALL='&comments=all'
printf -v CON '\e[1;34m'
printf -v COFF '\e[0m'
commfilter() {
xmllint --html --xpath \
'//div[@class="pgbox"]/div[@class="comment-header"]/..' - 2>/dev/null |
sed 's/<[^>]\+>//g;s/\t//g;s/\r$//
/Comment by:/,/[[:alnum:]]\+/{/^$/d};
s/>/>/g;s/</</g;
s/^\(Comment by:.*\)$/'"$CON"'\1'"$COFF"'/'
# line 1: strip html tags, remove tabs and ^M
# line 2: strip empty lines between timestamp and body
# line 3: decode HTML
# line 4: add color
}
[[ $1 = -a ]] && { showall=$ALL; shift; }
if ! (( $# )); then
if [[ ! -f PKGBUILD ]]; then
printf "error: no PKGBUILD found and no package name provided!\n"
exit 1
fi
eval $(grep '^pkgname=' PKGBUILD)
fi
pkgname=${1:-$pkgname}
if ! pkgID=$(cower -i --format '%i' "$pkgname" 2>/dev/null); then
printf "error: package \`%s' not found\n" "$pkgname"
exit 1
fi
curl -s "$AURURL/packages.php?ID=$pkgID$showall" | commfilter | fmt -sw$(tput cols)