あらかじめ設定した処理を実行する、いわゆるタスクランナーは多数あります。GulpやGradleなどが有名です。多くのタスクランナーはシステム向けで、数ヶ月後にメンテナンスするのが困難になったりします。 今回紹介するmaskはMarkdownファイルを使ったタスクランナーです。コメントも使えたりして、使い勝手が良さそうです。

maskの使い方

ファイルの例です。見出し部分が機能になります。 mask build のように指定します。

# Tasks For My Project

<!-- A heading defines the command's name -->

## build

<!-- A blockquote defines the command's description -->
> Builds my project

<!-- A code block defines the script to be executed -->
~~~sh
echo "building project..."
~~~

## serve

> Serve this directory

<!-- You must define OPTIONS right before your list of flags -->
**OPTIONS**
* port
    * flags: -p --port
    * type: string
    * desc: Which port to serve on

~~~sh
# Set a fallback port
PORT=${port:-8080}

if [[ "$verbose" == "true" ]]; then
    echo "Starting an http server on PORT: $PORT"
fi
python -m SimpleHTTPServer $PORT
~~~

maskではコード部のところで何の言語で実行するかを指定できます。shだけでなくnodeやPythonなども指定できます。オプションであったり、ヘルプも使えます。説明を書いておくことで、後々のメンテナンスがしやすくなるでしょう。

maskはRust製のオープンソース・ソフトウェア(MIT License)です。

jakedeichert/mask: ? A CLI task runner defined by a simple markdown file