Skip to content

Commit 01dc25a

Browse files
author
Mauko Quiroga
committed
Avoid one liners for clarity
1 parent 7205e82 commit 01dc25a

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

Makefile

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,39 @@ all: test
1313
## List all the available tasks.
1414
help:
1515
@## See https://gist.github.com/klmr/575726c7e05d8780505a.
16-
@sed -ne "/^## /{h;s/.*//;:d" -e "H;n;s/^## //;td" -e "s/:.*//;G;s/\\n## /---/;s/\\n/ /g;p;}" ${MAKEFILE_LIST} | awk -F --- -v n=$$(tput cols) -v i=19 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf"%s%*s%s ",a,-i,$$1,z;m=split($$2,w," ");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;printf"\n%*s ",-i," ";}printf"%s ",w[j];}printf"\n";}'
16+
@sed -n -e "/^## / { \
17+
h; \
18+
s/.*//; \
19+
:doc" \
20+
-e "H; \
21+
n; \
22+
s/^## //; \
23+
t doc" \
24+
-e "s/:.*//; \
25+
G; \
26+
s/\\n## /---/; \
27+
s/\\n/ /g; \
28+
p; \
29+
}" ${MAKEFILE_LIST} \
30+
| awk -F '---' \
31+
-v ncol=$$(tput cols) \
32+
-v indent=19 \
33+
-v col_on="$$(tput setaf 6)" \
34+
-v col_off="$$(tput sgr0)" \
35+
'{ \
36+
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
37+
n = split($$2, words, " "); \
38+
line_length = ncol - indent; \
39+
for (i = 1; i <= n; i++) { \
40+
line_length -= length(words[i]) + 1; \
41+
if (line_length <= 0) { \
42+
line_length = ncol - indent - length(words[i]) - 1; \
43+
printf "\n%*s ", -indent, " "; \
44+
} \
45+
printf "%s ", words[i]; \
46+
} \
47+
printf "\n"; \
48+
}'
1749

1850
## Uninstall project dependencies.
1951
uninstall:

0 commit comments

Comments
 (0)