小ネタです。
同僚でもある itchyny さんのOSS、itchyny/fillin は以下のように使える便利コマンド。
$ fillin echo {{message}} message: Hello, world! # you type here Hello, world! # fillin executes: echo 'Hello, world!'
めちゃくちゃ良い。
一方 Pixela とは、拙作の Web API サービス。
APIドキュメントもあります。
この2つの組み合わせのなにが便利なのかというと......、、たとえば僕は、その日の気分を「-50 〜 +50」の数値で記録する、ってのをやってみてるんですが(その様子)、手元の Mac から記録するには以下のようなコマンドを叩く必要があるわけです。
$ curl -X POST https://pixe.la/v1/users/a-know/graphs/emotion -H 'X-USER-TOKEN:thisissecret' -d '{"date":"20201018","quantity":"10","optionalData":"{\"event\":\"実家に帰った\"}"}'
日が変わると、当然以下のようにリクエスト内容を書き換える必要がある。
$ curl -X POST https://pixe.la/v1/users/a-know/graphs/emotion -H 'X-USER-TOKEN:thisissecret' -d '{"date":"20201019","quantity":"50","optionalData":"{\"event\":\"5000兆円ゲットした!\"}"}'
まぁ面倒くさい。毎日叩くようなものならなおさら。
それを、fillin
を使って以下のようにしておくと、
$ fillin curl -X POST https://pixe.la/v1/users/a-know/graphs/emotion -H 'X-USER-TOKEN:{{token}}' -d '{"date":"{{date}}","quantity":"{{quantity}}","optionalData":"{\"event\":\"{{event}}\"}"}' token: thisissecret date: 20201018 quantity: 10 event: 実家に帰った {"message":"Success.","isSuccess":true}
翌日以降になっても、実行するコマンド自体は履歴から呼び出したものを雑に実行しても大丈夫、ってわけだ。
$ fillin curl -X POST https://pixe.la/v1/users/a-know/graphs/emotion -H 'X-USER-TOKEN:{{token}}' -d '{"date":"{{date}}","quantity":"{{quantity}}","optionalData":"{\"event\":\"{{event}}\"}"}' token: thisissecret date: 20201019 quantity: 50 event: 5000兆円ゲットした! {"message":"Success.","isSuccess":true}
結論
itchyny/fillin が便利。