-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-wrapper.sh
More file actions
90 lines (69 loc) · 2.74 KB
/
basic-wrapper.sh
File metadata and controls
90 lines (69 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# Copyright (c) 2025 Marc Allgeier (fidpa)
# SPDX-License-Identifier: MIT
# https://github.com/fidpa/bash-markdown-link-validator
#
# Basic wrapper example - validates links in a single directory
#
# Usage: ./basic-wrapper.sh [OPTIONS]
#
# Copy this file to your documentation directory and customize
# the configuration section below.
set -uo pipefail
# ============================================================================
# CONFIGURATION - Customize these for your project
# ============================================================================
AREA_NAME="docs" # Display name for reports
EXCLUDE_DIRS="archive|deprecated" # Directories to exclude (regex)
# ============================================================================
# PATH SETUP - Adjust if your project structure differs
# ============================================================================
# This script's directory (where your docs are) - POSIX-compatible
readonly AREA_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
# Project root (parent of docs)
readonly PROJECT_ROOT="$(cd "$AREA_DIR/.." && pwd)"
# Main docs directory
readonly DOCS_DIR="$PROJECT_ROOT/docs"
# ============================================================================
# LIBRARY LOADING - Update path as needed
# ============================================================================
# Option 1: Installed globally
# LIBRARY_PATH="${HOME}/.local/lib/bash-markdown-link-validator/validate-links-core.sh"
# Option 2: In project's scripts/lib directory
# LIBRARY_PATH="$PROJECT_ROOT/scripts/lib/validate-links-core.sh"
# Option 3: Relative to this script (if examples/ is in the repo)
LIBRARY_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/src/validate-links-core.sh"
if [[ ! -f "$LIBRARY_PATH" ]]; then
echo "ERROR: Cannot find validate-links-core.sh at: $LIBRARY_PATH" >&2
echo "Please update LIBRARY_PATH in this script." >&2
exit 2
fi
# shellcheck source=/dev/null
source "$LIBRARY_PATH" || {
echo "ERROR: Failed to load library" >&2
exit 2
}
# ============================================================================
# MAIN
# ============================================================================
parse_args "$@"
setup_colors
print_validation_header
# Find markdown files
mapfile -t md_files < <(find_markdown_files "$AREA_DIR" "$EXCLUDE_DIRS")
if [[ ${#md_files[@]} -eq 0 ]]; then
echo "No markdown files found in $AREA_DIR"
exit 0
fi
echo "Found ${#md_files[@]} markdown files"
echo ""
# Run validation
if [[ $PARALLEL_JOBS -eq 1 ]]; then
validate_sequential "${md_files[@]}"
else
validate_parallel "${md_files[@]}"
fi
# Output summary
print_summary_report
# Exit with appropriate code
exit_with_status