1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 04:05:39 +01:00
svtplay-dl/scripts/diff_man_help.sh
Olof Johansson 7cde2ca8e7 Add script to diff --help and manpage
This is useful for making sure that the manpage is updated with regards to new
options.
2015-03-22 18:08:03 +01:00

41 lines
1.1 KiB
Bash

#!/bin/sh
# Make sure the options listed in --help and the manual are in sync.
diff_opts="$@"
diff_opts=${diff_opts:-"-u"}
TMPDIR=$(mktemp -d svtplay-man-test-XXXXXX)
[ "$TMPDIR" ] || {
echo "mktemp not available, using static dir"
TMPDIR=svtplay-man-test.tmp
[ ! -e "$TMPDIR" ] || {
echo "$TMPDIR already exists. Aborting."
exit 1
}
mkdir "$TMPDIR"
}
trap 'rm -rf "$TMPDIR"' EXIT TERM
# FIXME: *Currently* we don't have any =head3 that doesn't
# document an option. This is thus fragile to changes.
sed -nre 's/^=head3 //p' svtplay-dl.pod > $TMPDIR/options.man
./svtplay-dl --help | grep '^ *-' > $TMPDIR/options.help
# --help specific filtering
sed -i -re 's/ .*//' $TMPDIR/options.help
sed -i -re 's/ excl.*//' $TMPDIR/options.help
sed -i -re 's/^ *//' $TMPDIR/options.help
sed -i -re 's/OUTPUT/filename/g' $TMPDIR/options.help
for file in $TMPDIR/options.*; do
sed -i -re 's/, / /' $file
sed -i -re 's/ / /' $file
# Normalize order of --help -h vs -h --help
# "--help -h" => "-h --help"
perl -i -pe 's/^(-.(?: [^-][^ ]+)?) (--.*)/\2 \1/' $file
done
# There should be no difference.
diff $diff_opts $TMPDIR/options.*
#sha1sum $TMPDIR/options.*