Initial commit: add .gitignore and README
This commit is contained in:
31
lib/init.sh
Executable file
31
lib/init.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Initialize all common libraries
|
||||
# Usage: source "$(dirname "$0")/init.sh"
|
||||
#
|
||||
# This script loads all common libraries in the correct order.
|
||||
# Individual scripts can source this instead of sourcing each library separately.
|
||||
|
||||
# Get lib directory (this file's directory)
|
||||
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Get script directory if not set (try to get from calling script)
|
||||
if [ -z "${SCRIPT_DIR:-}" ]; then
|
||||
# Try to get from calling script (BASH_SOURCE[2] because init.sh adds one level)
|
||||
if [ -n "${BASH_SOURCE[2]:-}" ]; then
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[2]}")" && pwd)"
|
||||
elif [ -n "${BASH_SOURCE[1]:-}" ]; then
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[1]}")" && pwd)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Source libraries in order (dependencies first)
|
||||
source "${LIB_DIR}/common/colors.sh"
|
||||
source "${LIB_DIR}/common/logging.sh"
|
||||
source "${LIB_DIR}/common/utils.sh"
|
||||
source "${LIB_DIR}/common/validation.sh" 2>/dev/null || true
|
||||
source "${LIB_DIR}/common/error-handling.sh" 2>/dev/null || true
|
||||
source "${LIB_DIR}/config/env.sh" 2>/dev/null || true
|
||||
|
||||
# Log that libraries are loaded (only in debug mode)
|
||||
[ "${LOG_LEVEL:-2}" -ge 3 ] && log_debug "Common libraries loaded from ${LIB_DIR}"
|
||||
|
||||
Reference in New Issue
Block a user