From d957f7cf9359b426d5b0338bcdd1c778f6e06780 Mon Sep 17 00:00:00 2001 From: mhmdanas Date: Fri, 10 Mar 2023 21:10:16 +0000 Subject: Add xchangelog command I didn't make the other changes to the README myself, they were simply done when I ran `make README`. --- xchangelog | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 xchangelog (limited to 'xchangelog') diff --git a/xchangelog b/xchangelog new file mode 100755 index 0000000..e97cdf0 --- /dev/null +++ b/xchangelog @@ -0,0 +1,46 @@ +#!/bin/bash +# xchangelog PKGNAME - open package changelog + +XBPS_DISTDIR=$(xdistdir) || exit 1 + +pkg=$1 +[ -z "$pkg" ] && pkg=$(basename "$PWD") + +if [ -f "$pkg" ]; then + template="$pkg" +elif [ -f "$pkg/template" ]; then + template="$pkg/template" +elif [ -f "$XBPS_DISTDIR/srcpkgs/$pkg/template" ]; then + template="$XBPS_DISTDIR/srcpkgs/$pkg/template" +else + echo "No such template: $pkg" >&2 + exit 1 +fi + +. "$template" + +if [ -z "$changelog" ]; then + echo "No changelog defined in template" >&2 + exit 1 +fi + +if ! [ -t 1 ]; then + curl -s -- "$changelog" +elif curl -sI -w "%{content_type}" -o /dev/null -- "$changelog" | grep -i "^text/plain"; then + if [ -n "$PAGER" ]; then + curl -s -- "$changelog" | "$PAGER" + elif type less >/dev/null; then + curl -s -- "$changelog" | less + else + curl -s -- "$changelog" + fi +else + if type xdg-open >/dev/null; then + xdg-open "$changelog" + elif [ -n "$BROWSER" ]; then + "$BROWSER" "$changelog" + else + echo 'Cannot open changelog in web browser, please install xdg-open or define $BROWSER' >&2 + exit 1 + fi +fi -- cgit 1.4.1