test-documentation: Use getopt; don’t silently ignore multiple arguments.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-05-29 23:54:16 -07:00 committed by Tim Abbott
parent 8c249644b1
commit 0ca9c260ae
1 changed files with 23 additions and 18 deletions

View File

@ -8,24 +8,29 @@ color_message () {
loglevel=() loglevel=()
case $1 in usage () {
-h|--help) cat <<EOF
echo "--help, -h show this help message and exit" usage:
echo "--loglevel=LEVEL, -L LEVEL log level (default: ERROR)" --help, -h show this help message and exit
echo "--skip-check-links skip checking of links" --loglevel=LEVEL, -L LEVEL log level (default: ERROR)
echo "--skip-external-links skip checking of external links" --skip-check-links skip checking of links
exit 0 --skip-external-links skip checking of external links
;; EOF
-L|--loglevel) }
loglevel=("$1" "$2")
;; args="$(getopt -o hL: --long help,loglevel:,skip-check-links,skip-external-links -- "$@")" ||
--skip-check-links) { usage >&2; exit 1; }
skip_check_links=1 eval "set -- $args"
;; while true; do
--skip-external-links) case "$1" in
skip_external_links=1 -h|--help) usage; exit 0;;
;; -L|--loglevel) loglevel=("$1" "$2"); shift 2;;
esac --skip-check-links) skip_check_links=1; shift;;
--skip-external-links) skip_external_links=1; shift;;
--) shift; break;;
*) exit 1;;
esac
done
cd "$(dirname "$0")"/../docs cd "$(dirname "$0")"/../docs
rm -rf _build rm -rf _build