# Telegram API Creator Bot - Makefile
# Common dev / build / run shortcuts. Run `make help` for the list.

APP      := tg-apicreator-bot
PKG      := github.com/z/tg-apicreator-bot
GOFLAGS  := -trimpath
LDFLAGS  := -s -w

GO       := go

.PHONY: help tidy build run dev test fmt vet clean docker docker-up docker-down install-deps

help: ## Show available targets
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-18s\033[0m %s\n", $$1, $$2}'

install-deps: ## Download / tidy module dependencies
	$(GO) mod download
	$(GO) mod tidy

tidy: ## go mod tidy
	$(GO) mod tidy

fmt: ## Format source code
	$(GO) fmt ./...

vet: ## Run go vet
	$(GO) vet ./...

test: ## Run tests
	$(GO) test ./... -count=1

build: ## Build the production binary into ./bin
	@mkdir -p bin
	GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o bin/$(APP) ./main.go

run: build ## Build and run with config.yaml
	./bin/$(APP) -config config.yaml

dev: ## Run directly with go run (hot reload via re-run)
	$(GO) run main.go -config config.yaml

clean: ## Remove build artifacts
	rm -rf bin

docker: ## Build the Docker image
	docker build -t $(APP):latest .

docker-up: ##Start everything via docker compose
	docker compose up -d --build

docker-down: ## Stop docker compose stack
	docker compose down
