1#!/usr/bin/env bash
 2
 3set -euo pipefail
 4
 5usage() {
 6    echo "Usage: $0 [local|all] [--help]"
 7    echo "  local  Only check local links (default)"
 8    echo "  all    Check all links including remote ones"
 9    exit 1
10}
11
12check_mode="local"
13if [ $# -eq 1 ]; then
14    case "$1" in
15    "local") check_mode="local" ;;
16    "all") check_mode="all" ;;
17    "--help") usage ;;
18    *) echo "Invalid argument: $1" && usage ;;
19    esac
20else
21    usage
22fi
23
24cargo install lychee
25cd "$(dirname "$0")/.."
26
27if [ "$check_mode" = "all" ]; then
28    lychee --no-progress './docs/src/**/*'
29else
30    lychee --exclude '^http' './docs/src/**/*'
31fi
32#