.PHONY: install dev test lint format typecheck clean build-wheel build-deb build-all

install:
	pip install -e .

dev:
	pip install -e ".[dev]"
	pre-commit install

test:
	pytest -v --tb=short

test-cov:
	pytest --cov=sshctl --cov-report=term-missing --cov-fail-under=45

lint:
	ruff check src/ tests/

format:
	ruff format src/ tests/

format-check:
	ruff format --check src/ tests/

typecheck:
	mypy src/ tests/

check: lint format-check typecheck test

clean:
	rm -rf dist/ dist-deb/ build/ *.egg-info/ htmlcov/ .coverage coverage.xml .mypy_cache .ruff_cache .pytest_cache
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
	find . -type f -name '*.pyc' -delete

build-wheel:
	pip install build
	python -m build --wheel

build-deb: build-wheel
	cd linux && dpkg-buildpackage -us -uc -b
	mkdir -p dist-deb
	mv ./*.deb dist-deb/ 2>/dev/null || true

build-all: clean check build-wheel build-deb

release: clean check build-wheel build-deb
	@echo "Release artifacts:"
	@ls -la dist/*.whl dist-deb/*.deb 2>/dev/null || echo "No artifacts found"
