Skip to content

Instantly share code, notes, and snippets.

@umit
Created June 26, 2022 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umit/8bd7f357c6e2839fbc2412c94b2b0fbc to your computer and use it in GitHub Desktop.
Save umit/8bd7f357c6e2839fbc2412c94b2b0fbc to your computer and use it in GitHub Desktop.
Add help command to show all commands in Makefile
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} \
/^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
target01: ## This message will also show up when typing 'make help'
@echo does something
# Remember that targets can have multiple entries (if your target specifications are very long, etc.)
target02: ## This message will show up too!!!
target02: target00 target01
@echo does even more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment