Skip to content

Instantly share code, notes, and snippets.

@kitzberger
Created February 13, 2018 07:37
Show Gist options
  • Save kitzberger/3465b1ad0f6149cc4a86b6cfc5bdaefa to your computer and use it in GitHub Desktop.
Save kitzberger/3465b1ad0f6149cc4a86b6cfc5bdaefa to your computer and use it in GitHub Desktop.
# Help based on https://gist.github.com/prwhite/8168133 thanks to @nowox and @prwhite
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([\w-]+)\s*:.*\#\#(?:@([\w-]+))?\s(.*)$$/ }; \
print "\nusage: make [target ...]\n\n"; \
for (keys %help) { \
print "$$_:\n"; \
for (@{$$help{$$_}}) { \
$$sep = "." x (25 - length $$_->[0]); \
print " $$_->[0]$$sep$$_->[1]\n"; \
} \
print "\n"; \
}
help: ##@system show this help
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment