DEV Community

Discussion on: Makefiles for automation and better dev-UI

Collapse
 
vlasales profile image
Vlastimil Pospichal

I use Makefile similarly, but for some actions I chose git aliases - especially for $ PWD sensitive actions.
This Makefile seems too complex to me. I would extract help as a global Bash script for all projects.

help: ## This help dialog.
    @parse_makefile.sh $(MAKEFILE_LIST) "Hello to the AwesomeProject"
Collapse
 
konrad_126 profile image
konrad_126

That's a great idea, thnx :)

Collapse
 
vlasales profile image
Vlastimil Pospichal

$ cat parse_makefile.sh

#!/bin/bash
echo "Hello to the $1"
printf "%-30s %s\n" "target" "help"
printf "%-30s %s\n" "------" "----"
sed -ne 's/:.*## */:/p' Makefile |
    while IFS=':' read command info; do
            printf "\033[36m%-30s \033[0m%s\n"  "$command" "$info"
    done