APP_NAME := `sed -n 's/^ *name.*=.*"\([^"]*\)".*/\1/p' pyproject.toml`
APP_VERSION := `sed -n 's/^ *version.*=.*"\([^"]*\)".*/\1/p' pyproject.toml`

# Makefile help

.PHONY: header
header:
	@printf "\033[34mEnvironment\033[0m\n"
	@printf "\033[34m---------------------------------------------------------------\033[0m\n"
	@printf "\033[33mAPP_NAME: \033[0m"
	@printf "\033[35m$(APP_NAME)\033[0m\n"
	@printf "\033[33mAPP_VERSION: \033[0m"
	@printf "\033[35m$(APP_VERSION)\033[0m\n"
	@printf "\n"

.PHONY: usage
usage:
	@printf "\033[034mUsage\033[0m\n"
	@printf "\033[34m---------------------------------------------------------------\033[0m\n"
	@printf "\033[37mmake [options] \033[0m\n\n"

.PHONY: options
options:
	@printf "\033[34mOptions\033[0m\n"
	@printf "\033[34m---------------------------------------------------------------\033[0m\n"
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-22s\033[0m %s\n", $$1, $$2}' | sort


.PHONY: core
core:  ## Run a command in packages/core/Makefile (Usage: make core <command>)
	@$(MAKE) --no-print-directory -C packages/core $(filter-out $@, $(MAKECMDGOALS))

.PHONY: harness
harness:  ## Run a command in packages/harness/Makefile (Usage: make harness <command>)
	@$(MAKE) --no-print-directory -C packages/harness $(filter-out $@, $(MAKECMDGOALS))

.PHONY: mux
mux:  ## Run a command in packages/mux/Makefile (Usage: make mux <command>)
	@$(MAKE) --no-print-directory -C packages/mux $(filter-out $@, $(MAKECMDGOALS))

.PHONY: test
test:  ## Run tests (fast, offline)
	uv run pytest

%:
	@:
