12194 shaares
293 private links
293 private links
The post lists practices to improve user-experience of command-line interface.
Problematic patterns
- Borders in TUIs should always be drawn with characters specifically intended for textual interfaces (e.g., boxdraw characters).
- Borders should be used sparingly, as they end up causing issues when the window is re-sized
- Decorative content in CLI output should be limited, since the output of CLI utilities can be piped through other programs.
- Nearly all animated spinners are extremely problematic for screenreaders. A simple progress meter and/or numeric percentage combined with flags to enable/disable them is preferable.
- Excessive animation and color can harm users with attention and/or vestibular disorders, and some on the autism spectrum. Tools should respect the NO_COLOR environment variable.
Accessibility
- Does the tool is usable once sended in
espeak-ng? - Have a look to the WCAG
- Avoid ASCII-art
- Keep it boring to other common utilities to reduce the learning curve.
- Follow convention: POSIX-like options
- Be predictable with the options. The command only do one thing well.
Documentation
- Write man pages. If your utility has a config file with special syntax or vocabulary, write a dedicated man page for it in section 5 and mention it in a “SEE ALSO” section.
- Ennsure
whatisandaproposwork as intended after installing your man pages. - Try adding shell completions for your program, so users can tab-complete options.
- Use a well-understood
-h. It helps to generate shell completions. See https://www.busybox.net/ as example
Miscellaneous
- Delegate output wrapping or detect the number of columns and format output to fit
- Be safe. Addd a
--dry-runor equivalent option. - Disable the colors when the tool is not a TTY, or when the user explicitly enables them.
- Check the binary name or the packages first. It can already be used.
dnfcan help.
Opinionated
--helpshould be blazingly fast as user can be stressed using it- Include example usage in the man page and accompanying documentation.
- Send example usages to the tldr pages project if the tool gets popular.
- Include an extended list of example command invocations and expected output. Make that document double as a test suite.
- Make your man pages as similar to other man pages on the target OS as possible. Many programs parse man pages, and expect them to follow a predictable structure. w3mman handles hyperlinks; editer like vim support looking up man pages; Pandoc can convert man pages to a variety of different formats.
- Conform to tools that share a similar niche. If you’re using Rust to make a fast alternative to popular coreutils.
ripgreporfdfor Rust,go vetfor Go are good examples. - Make the output readable to both humans and machines
- Consider splitting related functionality between many executables (the UNIX way) or subcommands (like Git). See https://www.lucasfcosta.com/blog/ux-patterns-cli-tools#consistent-commands-trees for more
- Don’t conflate CLIs and TUIs. A CLI should be non-interactive; a TUI should be interactive.