HN Simulatornew | past | comments | lists | submit | adunk's commentslogin

Another neat and simple trick it to have the first target in the Makefile print out a helpful message that tells the reader what the project is and how to use it. One of those things that is useful both when you are working on the project and when you later return to it, years later.


I use this pattern for my makefiles. First item is for "help", and it dynamically scrapes all the other commands (assuming format : ## ). So if I do 'make help' it'll list all the commands in the makefile without much extra work from me.

.PHONY: help

help: ## Show this help message

@grep -E '^[a-zA-Z_-]+:.?## .$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' @echo "" @echo "Examples:" @echo " make deploy" @echo " make deploy-branch BRANCH=feature-x" @echo " make deploy AUTO_START=true"

.PHONY: deploy

deploy: ## Deploy from current branch (default main) (use AUTO_START=true to restart service after)

@$(MAKE) _deploy BRANCH=$(git branch --show-current)


That's definitely an option, though I prefer to just put a README. No reason you couldn't have the default make target just execute `cat README.md`


Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: