SOURCE_FILES?=$$(go list ./...)
TEST_PATTERN?=.
TEST_OPTIONS?=

setup: ## Install all the build and lint dependencies
	go get -u --insecure github.com/golang/dep/cmd/dep
	go get -u github.com/alecthomas/gometalinter
	gometalinter --install
	dep ensure

test: ## Run all the tests
	go test $(TEST_OPTIONS) -cover $(SOURCE_FILES) -coverprofile=coverage.out -run $(TEST_PATTERN) -timeout=30s

test_integration: ## Run the integration tests
	go test integration/*.go

test_integration_update_golden: ## Run the integration tests (and update the golden files)
	go test integration/*.go -update

cover: ## Show code coverage
	go tool cover -func=coverage.out

cover_html: ## Show code coverage as html
	go tool cover -html=coverage.out

lint: ## Lint the source
	bingo lint
	#gometalinter --vendor --disable-all \
	#	--enable=vet \
	#	--enable=gofmt \
	#	--enable=errcheck \
	#	--enable=golint \
	#	./...

build: ## Build a dev version 
	go build code.justin.tv/twitch/cli/cmd/twitch

install: ## Install it
	go install code.justin.tv/twitch/cli/cmd/twitch

# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## You found me
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help

