# Show available recipes
default:
    @just --list --unsorted

# Sync development dependencies (may update uv.lock if pyproject.toml changed)
sync:
    uv sync --group dev --all-extras

# Lint and format source code
lint:
    uv run ruff check --fix src/ tests/
    uv run ruff format src/ tests/

# Run static type checks with Astral ty
typecheck:
    uv run ty check src/

# Run tests
test *ARGS:
    uv run pytest -v {{ARGS}} tests/

# Run tests with coverage report
coverage:
    uv run pytest --cov=opscat --cov-report=term-missing tests/

# Build distribution packages
build:
    uv build -v

# Serve documentation locally
docs-serve:
    uv run zensical serve

# Build documentation
docs-build:
    uv run zensical build

# Remove build artifacts
clean:
    rm -rf dist/ site/ .pytest_cache/ htmlcov/ .coverage
    find src/ tests/ -type f -name "*.pyc" -delete
    find src/ tests/ -type d -name "__pycache__" -delete

# Run ansible-lint against roles and playbooks
ansible-lint:
    uv run --group ansible ansible-lint

# Run the full molecule test cycle for a role (create → prepare → converge → verify → destroy)
# Usage: just molecule-test nft_egress_routing
molecule-test role:
    cd roles/{{role}} && uv run --group ansible molecule test

# Apply the role inside the molecule container without destroying it afterwards
# Useful for iterating on the role during development.
# Usage: just molecule-converge nft_egress_routing
molecule-converge role:
    cd roles/{{role}} && uv run --group ansible molecule converge

# Run only the verify playbook against an already-converged molecule container
# Usage: just molecule-verify nft_egress_routing
molecule-verify role:
    cd roles/{{role}} && uv run --group ansible molecule verify

# Destroy the molecule container for a role (clean up after converge/verify)
# Usage: just molecule-destroy nft_egress_routing
molecule-destroy role:
    cd roles/{{role}} && uv run --group ansible molecule destroy
