Created
June 4, 2021 07:03
-
-
Save nokazn/5e8feb3456624d3a3de555bb3e8fe8ad to your computer and use it in GitHub Desktop.
Display help information for make commands
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/make -f | |
| .DEFAULT_GOAL := help | |
| .PHONY: help | |
| help: # Show all commands. | |
| @echo "📗 Displays help information for make commands." | |
| @echo "Commands:" | |
| # コマンド一覧 -> ":" で改行 -> ":" を含む行 (前半) の \s を ", " に置換、"#" を含む行 (後半) からコメントを抽出 -> ":" で分けた個所を再連結 -> column で整形 | |
| @grep -E '^[a-zA-Z]\S+(\s\S+)*:.*' ./Makefile \ | |
| | sed --regexp-extended -e "s/:/:\n/" \ | |
| | sed --regexp-extended -e "/:/ s/\s/, /g" -e "s/^.*[#|;]+\s*//" \ | |
| | sed --regexp-extended -e "N" -e "s/:\n/:/g;" -e "s/^/ /" \ | |
| | column -s ":" -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment