#!/usr/bin/env bash

required_commands=(
    clang-format
    clang-tidy
    wget
)

for cmd in "${required_commands[@]}"; do
    if ! command -v "$cmd" >/dev/null 2>&1; then
        echo "Error: required command '$cmd' is not installed." >&2
        exit 1
    fi
done

if [ -f .clang-tidy ]; then
    mv .clang-tidy .clang-tidy.bak
elif [ -f .clang-format ]; then
    mv .clang-format .clang-format.bak
fi

wget https://texturawasd.net/files/Config/.clang-format
wget https://texturawasd.net/files/Config/.clang-tidy

clang-tidy -fix "$1"
clang-format -i "$1"
