# Just commands for animate project

# Show available commands
@help:
    just --list

# Install package with all dev dependencies
install:
    uv pip install -e ".[dev,color]"

# Run tests with coverage
test:
    uv run pytest

# Format code with black
format:
    uv run black src/ tests/ examples/

# Lint code with ruff
lint:
    uv run ruff check src/ tests/ examples/

# Fix linting issues automatically
lint-fix:
    uv run ruff check src/ tests/ examples/ --fix

# Type check with mypy
type-check:
    uv run mypy src/animate

# Run all checks (format, lint, type-check, test)
check: format lint type-check test

# Run animation examples (spinner, planet, or cyber_text)
example name:
    @if [ "{{name}}" = "spinner" ]; then \
        uv run python examples/simple_spinner.py; \
    elif [ "{{name}}" = "planet" ]; then \
        uv run python examples/planet_earth.py; \
    elif [ "{{name}}" = "cyber_text" ]; then \
        uv run python examples/cyber_text.py; \
    else \
        echo "Unknown animation: {{name}}"; \
        echo "Available: spinner, planet, cyber_text"; \
        exit 1; \
    fi

# Build distribution packages
build:
    uv pip install build
    uv run python -m build

# Publish to PyPI (requires PYPI_TOKEN environment variable)
publish: build
    uv pip install twine
    uv run python -m twine upload dist/* --non-interactive

# Publish to TestPyPI for testing
publish-test: build
    uv pip install twine
    uv run python -m twine upload --repository testpypi dist/* --non-interactive

# Clean build artifacts and cache
clean:
    rm -rf build/ dist/ *.egg-info
    find . -type d -name __pycache__ -exec rm -rf {} +
    find . -type d -name .pytest_cache -exec rm -rf {} +
    find . -type d -name .mypy_cache -exec rm -rf {} +
    find . -type d -name .ruff_cache -exec rm -rf {} +
    rm -f .coverage

# Show version
version:
    @grep "version = " pyproject.toml | head -1 | cut -d'"' -f2
