Skip to content

Commit

Permalink
data/make_man.sh: check output of binary
Browse files Browse the repository at this point in the history
Since the manual page is partially generated using uv/hd-rum-transcode
output (for options), check if there is some output available.

Most importantly this should catch the situation when UG/reflector output
changes so that it is no more extracted to the manual page.
  • Loading branch information
MartinPulec committed Nov 15, 2023
1 parent 72ffd5c commit 01e525b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions data/make_man.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ run_asciidoc() {
"$exe" $opt manpage $VERBOSE "$1"
}

check_append_rm() {
if [ ! -s "$1" ]; then
echo "Could not obtain data from UG/reflector output!" >&2
rm "$1"
exit 3
fi
cat "$1" >> "$2"
rm "$1"
}

uv_man() {
ASCIIDOC=uv.1.txt

Expand All @@ -54,7 +64,9 @@ uv_man() {
== OPTIONS ==
EOF

"${UV_PATH}uv" --fullhelp | sed '0,/Options:/d' >> $ASCIIDOC
tmpfile=$(mktemp)
"${UV_PATH}uv" --fullhelp | sed '0,/Options:/d' > "$tmpfile"
check_append_rm "$tmpfile" $ASCIIDOC

bugreport_and_resources >> $ASCIIDOC
cat <<-'EOF' >> $ASCIIDOC
Expand Down Expand Up @@ -96,12 +108,16 @@ hd_rum_transcode_man() {
== OPTIONS ==
EOF

tmpfile=$(mktemp)
"${UV_PATH}hd-rum-transcode" -h |
awk '/where/{flag=1; next} flag{print}' | sed '/Please/,$d' >> $ASCIIDOC
awk '/where/{flag=1; next} flag{print}' | sed '/Please/,$d' > "$tmpfile"
check_append_rm "$tmpfile" $ASCIIDOC

printf '\n== NOTES ==\n' >> $ASCIIDOC
tmpfile=$(mktemp)
"${UV_PATH}hd-rum-transcode" -h | outdent_output | escape_apostrophe |
sed -n '/Please/,$p' >> $ASCIIDOC
sed -n '/Please/,$p' > "$tmpfile"
check_append_rm "$tmpfile" $ASCIIDOC

# below heredoc contains contiunation of NOTES section
cat <<-'EOF' >> $ASCIIDOC
Expand Down

0 comments on commit 01e525b

Please sign in to comment.