Join Nostr
2026-01-05 13:11:34 UTC

Grégoire Locqueville on Nostr: PSA: When writing documentation for a terminal command or anything with a rigid ...

PSA: When writing documentation for a terminal command or anything with a rigid syntax, always include fully spelt-out examples (i.e. examples that you could directly copypaste and they would run, if the context were right).

Say you're writing a multi-user CLI todo list application and documenting the function "add-item". Then this:

$ add-item <item> --user <user> --priority PRIORITY

is not a (fully spelt-out) example, because it's not runnable as is. As a consequence, as a user, I can't apply it without sorting out a couple questions first: is "<>" part of the command syntax, or is it just here to denote the fact that users should substitute a string? What about the caps?

To contrast, here's a fully spelt-out example:

$ add-item get-groceries --user alex --priority 3

This might not be copypastable as is, of course, because chances are there's no user named "alex" in your setup, but it's as close as possible: if your setup did have the user "alex", the command would work.

(note that even though, say, `add-item item` would also technically work, it's not ideal, because "item" might be either a fixed keyword, or a free string, so users don't know whether they're allowed to put in another string in that slot. Prefer examples that are as real-lifey and specific as possible, like `add-item get-groceries`)

If your examples are not fully spelt-out, they're not examples, they're specification, and you're assuming that users know the specification syntax.