# {{project_name}} - Rust CLI Binary Makefile
# Generated by Pragmatic AI Labs MCP Agent Toolkit (pmat)

.PHONY: all check format lint test bench build build-release run clean install help

# Default target: run all checks and build
all: format check lint test build

# Type check the code
check:
	cargo check{{#if target}} --target {{target}}{{/if}}{{#if features}} --features "{{#each features}}{{this}}{{#unless @last}},{{/unless}}{{/each}}"{{/if}}

# Format code with rustfmt
format:
	cargo fmt --all

# Lint with clippy
lint:
	cargo clippy --all-targets{{#if target}} --target {{target}}{{/if}}{{#if features}} --features "{{#each features}}{{this}}{{#unless @last}},{{/unless}}{{/each}}"{{/if}} -- -D warnings

# Run tests
test:
{{#if has_tests}}	cargo test{{#if target}} --target {{target}}{{/if}}{{#if features}} --features "{{#each features}}{{this}}{{#unless @last}},{{/unless}}{{/each}}"{{/if}}{{else}}	@echo "No tests configured"{{/if}}

# Run benchmarks
bench:
{{#if has_benchmarks}}	cargo bench{{#if target}} --target {{target}}{{/if}}{{#if features}} --features "{{#each features}}{{this}}{{#unless @last}},{{/unless}}{{/each}}"{{/if}}{{else}}	@echo "No benchmarks configured"{{/if}}

# Build debug binary
build:
	cargo build{{#if target}} --target {{target}}{{/if}}{{#if features}} --features "{{#each features}}{{this}}{{#unless @last}},{{/unless}}{{/each}}"{{/if}}

# Build release binary
build-release:
	cargo build --release{{#if target}} --target {{target}}{{/if}}{{#if features}} --features "{{#each features}}{{this}}{{#unless @last}},{{/unless}}{{/each}}"{{/if}}

# Run the application
run:
	cargo run{{#if target}} --target {{target}}{{/if}}{{#if features}} --features "{{#each features}}{{this}}{{#unless @last}},{{/unless}}{{/each}}"{{/if}}{{#if default_args}} -- {{default_args}}{{/if}}

# Clean build artifacts
clean:
	cargo clean

# Install the binary to cargo bin directory
install: build-release
	cargo install --path .{{#if target}} --target {{target}}{{/if}}{{#if features}} --features "{{#each features}}{{this}}{{#unless @last}},{{/unless}}{{/each}}"{{/if}}

# Show help
help:
	@echo "{{project_name}} - Available targets:"
	@echo "  all           - Run format, check, lint, test, and build"
	@echo "  check         - Type check the code"
	@echo "  format        - Format code with rustfmt"
	@echo "  lint          - Run clippy linter"
	@echo "  test          - Run tests"
	@echo "  bench         - Run benchmarks"
	@echo "  build         - Build debug binary"
	@echo "  build-release - Build optimized release binary"
	@echo "  run           - Run the application"
	@echo "  clean         - Remove build artifacts"
	@echo "  install       - Install the binary"
	@echo "  help          - Show this help message"