Files
skills/skills/common-tooling/scripts/verify-tools.sh
T
2026-10-19 14:16:52 -07:00

33 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Report which tools from tools.tsv are on PATH. Exit 1 if a core one is missing.
#
# Usage: verify-tools.sh [-q] -q prints only what is missing
set -euo pipefail
here=$(cd -- "$(dirname -- "$(readlink -f -- "$0")")" && pwd)
quiet=false
[ "${1:-}" = "-q" ] && quiet=true
status=0
while read -r bin need _; do
case $bin in '' | '#'*) continue ;; esac
if command -v -- "$bin" >/dev/null; then
$quiet || printf ' ok %s\n' "$bin"
elif [ "$need" = core ]; then
printf ' MISSING %s\n' "$bin"
status=1
else
printf ' missing %s (optional)\n' "$bin"
fi
done <"$here/tools.tsv"
# Present is not enough for the one tool whose major versions disagree on syntax.
if command -v dasel >/dev/null && ! dasel version 2>/dev/null | grep -q '^v\?3\.'; then
printf ' WRONG dasel is not v3 (%s); the skill documents v3 syntax\n' \
"$(dasel --version 2>/dev/null || dasel version 2>/dev/null)"
status=1
fi
[ "$status" = 0 ] || printf 'install the missing ones with %s/install-tools.sh\n' "$here"
exit "$status"