Created
December 8, 2016 20:22
-
-
Save supermario/d3143fedc07a50b172964131e4184ac1 to your computer and use it in GitHub Desktop.
Pretty make help
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
somecommand: #App# Description of some command | |
somebashcommand | |
someothercommand: #Development# Description of some other command | |
someotherbashcommand | |
help: | |
@./scripts/makefile-help.sh ./Makefile | |
.DEFAULT_GOAL := help |
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
#!/usr/bin/env bash | |
#set -ex | |
MAKEFILE=$1 | |
function print_section() { | |
local section_name | |
local filter | |
section_name="$1" | |
echo | |
echo "${section_name}" \ | |
| awk '{printf "\033[32m%-15s\033[0m \n", $1}' | |
filter='^[a-zA-Z_-]+:.*?#'$section_name'# .*$$' | |
grep -E "$filter" $MAKEFILE \ | |
| awk 'BEGIN {FS = ":.*?#'$section_name'# "}; {printf "\033[36m%-15s\033[0m %s\n", $1, $2}' | |
} | |
print_section "App" | |
print_section "Development" | |
print_section "Tools" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment