Skip to content

Instantly share code, notes, and snippets.

@supermario
Created December 8, 2016 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supermario/d3143fedc07a50b172964131e4184ac1 to your computer and use it in GitHub Desktop.
Save supermario/d3143fedc07a50b172964131e4184ac1 to your computer and use it in GitHub Desktop.
Pretty make help
somecommand: #App# Description of some command
somebashcommand
someothercommand: #Development# Description of some other command
someotherbashcommand
help:
@./scripts/makefile-help.sh ./Makefile
.DEFAULT_GOAL := help
#!/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