LoginSignup
9
8

More than 5 years have passed since last update.

Mustache のコマンドラインツールを Go で作った

Posted at

Musta

Go の習作で、前から欲しかった小さなツールを作ってみました。
https://github.com/shiwano/musta
リポジトリはここ。

インストール

Mac の人は brew でインストールできます。

brew tap shiwano/formulas
brew install musta

それ以外の環境の人は、 releases のバイナリを直接ダウンロードするか、go get で。

使い方

使い方はシンプルで、テンプレートファイルがある場合は、

$ cat template.mustache
foo: {{foo}}
$ musta -t template.mustache foo=bar
foo: bar

こんな感じでテンプレートファイル名と key=value の引数を与えてあげることで、文字列を生成できます。

$ musta -t template.mustache foo.bar=1 qux=1,2,3

引数はこんな感じのも OK で、

$ cat args.json | musta -T 'foo: {{foo}}' >> result.txt

テンプレート文字列を -T | --template-data オプションで直接渡したり、JSON データをパイプで渡したりもできます。

いろいろ凝った文字列生成をシェル芸でやるのに疲れた人とか、マルチプラットフォームで同じツールで文字列生成したいみたいな人に試してもらえたらいいかなーという感じのツールです。

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8