Created
October 3, 2019 20:22
-
-
Save elfsternberg/992f5de76c1d7b5af7f5e6daf32688ce to your computer and use it in GitHub Desktop.
A Makefile recipe for attaching short help messages to targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: default help | |
default: help | |
help: ## Print this help message | |
@M=$$(perl -ne 'm/^((\w|-)*):.*##/ && print length($$1)."\n"' Makefile | \ | |
sort -nr | head -1) && \ | |
perl -ne "m/^((\w|-)*):.*##\s*(.*)/ && print(sprintf(\"%s: %s\t%s\n\", \$$1, \" \"x($$M-length(\$$1)), \$$3))" Makefile | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment