# Makefile for mdget testing suite

# Default target
.PHONY: all
all: test-all

# Build mdget binary
.PHONY: build
build:
	@echo "Building mdget..."
	@go build -o bin/mdget ./cmd/mdget.go
	@echo "Built: bin/mdget"

# Clean build artifacts
.PHONY: clean
clean:
	@echo "Cleaning up..."
	@rm -rf bin/ test-output/ tmp/ *.test
	@echo "Clean complete"

# Test targets
.PHONY: test-all
test-all: test-args test-http test-output test-errors test-conversion test-build
	@echo "✅ All tests passed!"

.PHONY: test-args
test-args:
	@echo "Testing command-line arguments..."
	@cd test && go run test_helper.go test_args.go

.PHONY: test-http
test-http:
	@echo "Testing HTTP connectivity..."
	@cd test && go run test_helper.go test_http.go

.PHONY: test-output
test-output:
	@echo "Testing file output..."
	@cd test && go run test_helper.go test_output.go

.PHONY: test-errors
test-errors:
	@echo "Testing error conditions..."
	@cd test && go run test_helper.go test_errors.go

.PHONY: test-conversion
test-conversion:
	@echo "Testing HTML to Markdown conversion..."
	@cd test && go run test_helper.go test_conversion.go

.PHONY: test-build
test-build:
	@echo "Testing build and execution..."
	@cd test && go run test_helper.go test_build.go

# Helper targets
.PHONY: help
help:
	@echo "mdget Testing Suite"
	@echo ""
	@echo "Usage:"
	@echo "  make                 - Run all tests"
	@echo "  make build           - Build mdget binary"
	@echo "  make clean           - Clean build artifacts"
	@echo "  make test-all        - Run all tests"
	@echo "  make test-args       - Test command-line arguments"
	@echo "  make test-http       - Test HTTP connectivity"
	@echo "  make test-output     - Test file output"
	@echo "  make test-errors     - Test error conditions"
	@echo "  make test-conversion - Test HTML to Markdown conversion"
	@echo "  make test-build      - Test build and execution"
	@echo "  make help            - Show this help"

# Variables
BINARY_PATH ?= bin/mdget