Skip to content

Instantly share code, notes, and snippets.

@cessor
Last active February 26, 2022 08:54
Show Gist options
  • Save cessor/93a9198b09113840b6c76beeff6b4094 to your computer and use it in GitHub Desktop.
Save cessor/93a9198b09113840b6c76beeff6b4094 to your computer and use it in GitHub Desktop.
.DEFAULT_GOAL := help
.PHONY: help
# Source (So cool, thanks): https://daniel.feldroy.com/posts/autodocumenting-makefiles
define HELP_TEXT
import re,sys;
tasks = []
for line in sys.stdin:
match = re.match(r'^([a-zA-Z0-9_\.\-]+):.*?##(.*)$$', line)
if not match: continue
tasks.append("%-10s %s" % match.groups())
print('\n'.join(tasks))
endef
export HELP_TEXT
DESCRIPTION="Description"
help: ## Print this help
@echo
@echo $(DESCRIPTION)
@echo
@python -c "$$HELP_TEXT" < $(MAKEFILE_LIST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment