Writing Good Command Line Tools

By Deane Barker on October 21, 2014

Hints for writing Unix tools: I love command line programming, and this is some great advice for making Unix tools that can apply to everything. Beyond the actual advice here, I love the philosophical underpinning behind it – be non-opinionated, share well with others, don’t assume what the user wants to do, etc.  Good Unix programming is marked by a lack of narcissism.

Output should be free from headers or other decoration. Superflous output will frustrate users who are trying to parse tool output. Headers and decoration tend to be less regular and more idiosyncratic than the structured data you’re really trying to get at. Don’t do it.

[…] Treat a tool’s output as an API. Your tool will be used in contexts beyond your own imagination. If a tool’s output format is changed, other tools that compose or otherwise build on its output will invariably break—you have broken the API contract.

If you want more than this, it’s essentially scaled-down version of The Art of Unix Programming, which I haven’t read in years, but suddenly feel like I should again.