- Contents -
Makefile をタスクランナーとして使うのが結構便利なので、
Go言語以外のプロジェクトでも何かと使ったりしているんですが 、
簡単にUsageが出力できるといいなぁと思い、 make2help からもうちょっと発展させてみました。
行頭の"##" をキーワードに、
タスクと、変数の一行上にそれぞれコメントを記述する事が出来ます。
make2usage
https://gitlab.com/tyabuta/go-make2usage
download
Mac, Windows, Linux用にビルドしたものをおいているので、
ここからダウンロードする事もできます。
https://gitlab.com/tyabuta/go-make2usage/tags
install
go get -v -u gitlab.com/tyabuta/go-make2usage/cmd/make2usage
make2usage --help
$ make2usage
NAME:
make2usage - Generate usage from Makefiles.
USAGE:
make2usage [options] <Makefile, ...>
VERSION:
0.1.0
AUTHOR:
tyabuta <gmforip@gmail.com>
OPTIONS:
--all-variable, -V show all variable
--all-command, -C show all command
--help, -h show help
--version, -v print the version
記載例
Makefile サンプル
## 変数への説明書きができます
## 複数行記載する事も可能
PWD=$(shell pwd)
## タスクへの説明書きができます
task1:
@echo task3
usage:
@make2usage $(MAKEFILE_LIST)
.PHONY: task1 usage
出力結果
$ make usage
USAGE
make <commands> [variables]
VARIABLES
PWD -- 変数への説明書きができます
複数行記載する事も可能
COMMANDS
task1 -- タスクへの説明書きができます
おしまい
Songmuさんのmake2helpを参考にさせてもらいました。
https://github.com/Songmu/make2help