From b6e065b0d9c3f56e587b0ef49e821def03779c8b Mon Sep 17 00:00:00 2001 From: Andrzej Wasiak Date: Wed, 3 Oct 2018 15:59:52 +0200 Subject: [PATCH] added MakeHelp (#21) * added MakeHelp * stop gendocs --- .travis.yml | 2 +- bin/MakeHelp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 bin/MakeHelp diff --git a/.travis.yml b/.travis.yml index 9335147..c22456a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,4 @@ install: script: - vendor/phpunit/phpunit/phpunit --coverage-clover build/logs/clover.xml after_success: -- bash .travis_docgen.sh \ No newline at end of file +#- bash .travis_docgen.sh \ No newline at end of file diff --git a/bin/MakeHelp b/bin/MakeHelp new file mode 100644 index 0000000..5620ae3 --- /dev/null +++ b/bin/MakeHelp @@ -0,0 +1,35 @@ +.DEFAULT_GOAL := help +.PHONY: help + +HELP_TARGET_MAX_CHAR_NUM ?= 30 +SUBPROJECTS ?= +BOLD := $(shell tput -Txterm bold) +GREEN := $(shell tput -Txterm setaf 2) +YELLOW := $(shell tput -Txterm setaf 3) +WHITE := $(shell tput -Txterm setaf 7) +RESET := $(shell tput -Txterm sgr0) + +.ONESHELL: +## Shows this help +help: + @echo '${BOLD}Info${RESET}' + @echo ' ${YELLOW}${INFO}${RESET}' + @echo '${BOLD}Usage:${RESET}' + @echo ' ${YELLOW}make${RESET} ${GREEN}${EXTRA_MAKE_ARGS} ${RESET}' + @echo '${BOLD}Subprojects:${RESET}' + @printf ' %s\n' $(foreach subproject,$(SUBPROJECTS),"${GREEN}${subproject}${RESET}") + @echo '${BOLD}Targets:${RESET}' + @awk '/^(.+):/ { \ + helpMessage = match(lastLine, /^## (.*)/); \ + if (helpMessage) { \ + helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ + is_subproject_target = match($$1, /^.+_subproject.+:/); \ + if (is_subproject_target) { \ + helpCommand = substr($$2, 0, index($$2, ":")-2)""; \ + } else { \ + helpCommand = substr($$1, 0, index($$1, ":")-1); \ + } \ + printf " ${YELLOW}%-$(HELP_TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ + } \ + } \ + { lastLine = $$0 }' $(MAKEFILE_LIST) \ No newline at end of file