#!/usr/bin/env just --justfile

mod docs

source_dirs := "src/ tests/"

# Lint python source code
lint:
    pyflakes {{ source_dirs }}
    black --quiet --check {{ source_dirs }}
    zuban check {{ source_dirs }}

# Format python source code and other support files
format: && docs::format
    black --quiet {{ source_dirs }}
    mdformat README.md
    {{ just_executable() }} --fmt --unstable

# Run tests
test *args:
    pytest {{ args }}

# Build distribution
build:
    python -m build

pre-commit := f"""
  #!/bin/sh
  PATH={{`dirname "$(which python)"`}}:$PATH just lint test"""

# Install recommended git hooks. Do this after activating your virtual environment
install-hooks:
    echo '{{ pre-commit }}' > .git/hooks/pre-commit
    chmod +x .git/hooks/pre-commit
