one realization from working on Netlify's CLI is that the CLI framework we used, oclif, didn't provide a great user experience out of the box.
Emphasis on great: it does a lot of nice things, like offering flag and argument parsing, help documentation, and pluggability. That's good for the CLI developer. But what about the CLI user?
- Idiomatic oclif code often checks for required preconditions, and if it doesn't exist, it prints a warning and then
process.exit(1)
. - Decent code prints a helpful warning telling the user what they got wrong. It is informative.
- Better code offers a prompt, creates a file, or something similar to solve the precondition before proceeding. (possibly recursively). It is intent-based.
- Great code remembers past inputs to prompts and uses that to offer useful defaults. It is adaptive.