Craft
6 min read
The boring parts of a command-line tool
Exit codes, help text, colour that turns itself off, and other details that make a tool feel finished.

The interesting part of a command-line tool is what it does. The part people remember is everything around it.
Say what you did
Every command in Tern prints exactly what changed. Not done, not success: the flag name, the old value and the new one.
Respect the pipe
If output is going to another program, drop the colour and the decoration. If a person is reading it, add them back. Check whether standard output is a terminal, once, at the start.
Exit codes are an interface
Zero means it worked. One means you did something wrong. Two means the tool did. Write it down in the help text and never change it.
Written by
Iri Halvorsen, software engineer in Bergen
More / ls -t ./writing

