aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow/assert-manpages.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-07-27 14:24:01 -0300
committerEuAndreh <eu@euandre.org>2021-07-27 15:44:45 -0300
commit7bf0f2319442ee153cc656b72fa660c709f6a0cd (patch)
treeddae5f4ed3a7431bf026d3a64f9ff06615231804 /aux/workflow/assert-manpages.sh
parentaux/: Update, adjust Makefile (diff)
downloadgistatic-7bf0f2319442ee153cc656b72fa660c709f6a0cd.tar.gz
gistatic-7bf0f2319442ee153cc656b72fa660c709f6a0cd.tar.xz
Re-setup repository using C over Rust
Diffstat (limited to 'aux/workflow/assert-manpages.sh')
-rwxr-xr-xaux/workflow/assert-manpages.sh220
1 files changed, 220 insertions, 0 deletions
diff --git a/aux/workflow/assert-manpages.sh b/aux/workflow/assert-manpages.sh
new file mode 100755
index 0000000..f9a6807
--- /dev/null
+++ b/aux/workflow/assert-manpages.sh
@@ -0,0 +1,220 @@
+#!/bin/sh
+set -eu
+
+TLD="$(cat aux/tld.txt)"
+. aux/lib.sh
+
+IN_PLACE=false
+while getopts 'l:n:m:i' flag; do
+ case "$flag" in
+ n)
+ PROJECT="$OPTARG"
+ ;;
+ m)
+ MAILING_LIST="$OPTARG"
+ ;;
+ i)
+ IN_PLACE=true
+ ;;
+ l)
+ LANGS="$OPTARG"
+ ;;
+ *)
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+assert_arg() {
+ if [ -z "$1" ]; then
+ echo "Missing $2" >&2
+ exit 2
+ fi
+}
+
+assert_arg "${PROJECT:-}" '-n PROJECT'
+assert_arg "${MAILING_LIST:-}" '-m MAILING_LIST'
+assert_arg "${LANGS:-}" '-l LANGS'
+
+
+EXPECTED_EN="$(mkstemp)"
+cat <<EOF | sed 's|-|\\-|g' >> "$EXPECTED_EN"
+
+
+.SH AUTHORS
+
+.MT eu@euandre.org
+EuAndreh
+.ME
+and contributors.
+
+
+.SH BUGS
+
+.IP \(bu
+Report bugs to the
+.MT ~euandreh/$MAILING_LIST@lists.sr.ht
+mailing list
+.ME .
+Use the subject "\f(CR[$PROJECT] BUG or TASK:
+<description>\fR".
+.IP \(bu
+Browse bugs
+.UR https://$TLD/$PROJECT/TODOs.html
+online
+.UE .
+.IP \(bu
+.UR https://$TLD/$PROJECT/en/
+Homepage
+.UE .
+.IP \(bu
+.UR https://lists.sr.ht/~euandreh/$MAILING_LIST?search=%5B$PROJECT%5D
+Comments and discussions
+.UE .
+EOF
+
+EXPECTED_PT="$(mkstemp)"
+cat <<EOF | sed 's|-|\\-|g' >> "$EXPECTED_PT"
+
+
+.SH AUTORES
+
+.MT eu@euandre.org
+EuAndreh
+.ME
+e colaboradores.
+
+
+.SH BUGS
+
+.IP \(bu
+Relate bugs na
+.MT ~euandreh/$MAILING_LIST@lists.sr.ht
+lista de discussão
+.ME .
+Use o assunto "\f(CR[$PROJECT] BUG ou TASK:
+<descrição>\fR".
+.IP \(bu
+Veja os bugs
+.UR https://$TLD/$PROJECT/TODOs.html
+online
+.UE .
+.IP \(bu
+.UR https://$TLD/$PROJECT/pt/
+Página inicial
+.UE .
+.IP \(bu
+.UR https://lists.sr.ht/~euandreh/$MAILING_LIST?search=%5B$PROJECT%5D
+Comentários e discussões
+.UE .
+EOF
+
+EXPECTED_FR="$(mkstemp)"
+cat <<EOF | sed 's|-|\\-|g' >> "$EXPECTED_FR"
+
+
+.SH AUTEURS
+
+.MT eu@euandre.org
+EuAndreh
+.ME
+et les contributeurs.
+
+
+.SH BUGS
+
+.IP \(bu
+Soumettre un bogue dans la
+.MT ~euandreh/$MAILING_LIST@lists.sr.ht
+liste
+de diffusion
+.ME .
+Utilise le sujet "\f(CR[$PROJECT] BUG ou TASK:
+<description>\fR".
+.IP \(bu
+Parcourir les bogues
+.UR https://$TLD/$PROJECT/TODOs.html
+en
+ligne
+.UE .
+.IP \(bu
+.UR https://$TLD/$PROJECT/fr/
+Page d'accueil
+.UE .
+.IP \(bu
+.UR https://lists.sr.ht/~euandreh/$MAILING_LIST?search=%5B$PROJECT%5D
+Commentaires et discussions
+.UE .
+EOF
+
+EXPECTED_EO="$(mkstemp)"
+cat <<EOF | sed 's|-|\\-|g' >> "$EXPECTED_EO"
+
+
+.SH AŬTOROJ
+
+.MT eu@euandre.org
+EuAndreh
+.ME
+kaj la kontribuuloj.
+
+
+.SH MISFUNKCIOJ
+
+.IP \(bu
+Raportu misfunkcioj al la
+.MT ~euandreh/$MAILING_LIST@lists.sr.ht
+dissendolisto
+.ME .
+Uzu la subjekton "\f(CR[$PROJECT] BUG aŭ TASK:
+<priskribo>\fR".
+.IP \(bu
+Foliumu misfunkcioj
+.UR https://$TLD/$PROJECT/TODOs.html
+rete
+.UE .
+.IP \(bu
+.UR https://$TLD/$PROJECT/eo/
+Ĉefpaĝo
+.UE .
+.IP \(bu
+.UR https://lists.sr.ht/~euandreh/$MAILING_LIST?search=%5B$PROJECT%5D
+Komentoj kaj diskutoj
+.UE .
+EOF
+
+
+for from_f in "$@"; do
+ for lang in $LANGS; do
+ case "$lang" in
+ en)
+ EXPECTED="$EXPECTED_EN"
+ ;;
+ pt)
+ EXPECTED="$EXPECTED_PT"
+ ;;
+ fr)
+ EXPECTED="$EXPECTED_FR"
+ ;;
+ eo)
+ EXPECTED="$EXPECTED_EO"
+ ;;
+ *)
+ printf 'Unsupported lang: %s\n' "$lang" >&2
+ exit 2
+ ;;
+ esac
+
+ f="$(echo "$from_f" | sed "s/\.en\./.$lang./")"
+ if ! tail -n "$(wc -l < "$EXPECTED")" "$f" |
+ diff - "$EXPECTED"; then
+ echo "Missing metadata at the end of \"$f\" file"
+ if [ "$IN_PLACE" = true ]; then
+ cat "$EXPECTED" >> "$f"
+ else
+ exit 1
+ fi
+ fi
+ done
+done