Recently I’ve created a tiny site called tool.haus. It’s a repository for all the small utilities I write from now on.
On that note, I thought about the API that these little utilities should expose.
Most bash scripts or utilities use command line arguments to define behavior. This is great for humans but can be a pain when calling scripts from other scripts.
My current strategy is to implement the same API in all scripts:
JSON -> STDIN
Debug output -> STDERR
JSON -> STDOUT
All options, flags and input data are encompassed in the input JSON. Likewise, all output is exposed as JSON. Human-readable output is sent to STDERR.
We’ll see if this utility convention works out!