commit f99c5dd2c488f132024b38aa71b0be18ab4b6fd3 parent bffe32411e8ded537c5615ea054b43b3f7334bcd Author: Thien-Thi Nguyen <ttn@gnuvola.org> Date: Sun, 24 Apr 2022 09:17:30 -0400 add --help/--version support * format.sh (me, version): New vars. <top-level>: Handle ‘--help’ on command line. <top-level>: Likewise for ‘--version’. (template): New var. <top-level>: Use ‘recfmt -f’ and ‘$template’. Diffstat:
| M | format.sh | | | 27 | ++++++++++++++++++++++++++- |
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/format.sh b/format.sh @@ -1,2 +1,27 @@ #!/bin/sh -exec recfmt "`cat $1`" +## +# Usage: format.sh TEMPLATE +# +# This runs recfmt w/ template file TEMPLATE on stdin, writing to stdout. +## +me=$(basename $0) + +version='1.1' +# 1.1 -- add --help/--version support +# 1.0 -- initial release + +if [ x"$1" = x--help ] ; then + sed '/^##/,/^##/!d;/^##/d;s/^# //g;s/^#$//g' $0 + exit 0 +fi + +if [ x"$1" = x--version ] ; then + echo $me '(gana)' $version + exit 0 +fi + +template="$1" + +exec recfmt -f "$template" + +# format.sh ends here