#!/bin/bash

usage=()

usage+=("  $0 tests - run tests")
tests() {
    uv run pytest "$@"
    lint
}

usage+=("  $0 refmt - reformat code")
refmt() {
    uv run ruff check --select I --fix
    uv run ruff format
}

usage+=("  $0 lint - run linting")
lint() {
    uv run ruff check
    uv run ruff format --diff
    uv run mypy sql_athame/**.py tests/**.py
}

usage+=("  $0 bump2version {major|minor|patch} - bump version number")
bump2version() {
    uv run bump2version "$@"
}

cmd=$1
shift

if ! declare -f "$cmd" >/dev/null; then
    echo "Usage:"
    for line in "${usage[@]}"; do echo "$line"; done
    exit 1
fi

set -o xtrace

"$cmd" "$@"
