book icon indicating copy to clipboard operation
book copied to clipboard

Book: Chapter on "writing robust CLI applications"

Open killercup opened this issue 7 years ago • 1 comments

Inspired by @vorner's comment (https://github.com/rust-lang-nursery/cli-wg/pull/105#discussion_r240003491).

We should look into adding an in-depth chapter on how to write applications in a robust and well-behaved way. For example, when an application was forcefully terminated (kill -9, power outage, …), it should still be possible to start it again without any issues.

For this to work, several aspects need to be considered. For example,

  • cleaning up or overwriting temporary files from a previous run without issues
  • atomically writing config files so they are not corrupted

Other "robustness" aspects that come to mind:

  • Follow sane resource limits for the current OS (e.g. not open millions of file descriptors on macOS)
  • Try to be both forward and backward compatible with config files and CLI arguments

Noe: As @vorner correctly pointed out, this does not need to be specific to CLI applications!

killercup avatar Dec 08 '18 13:12 killercup

Other things that come into mind:

  • If there are any caches, should the app purge it automatically under some circumstances (max size, age of entries, corrupt entries, corrupt whole cache)
  • Running multiple instances of the app
  • 😈 What happens under bad conditions ‒ will it write partial files when it runs out of space? Will it try to load and use that file next time?

vorner avatar Dec 08 '18 14:12 vorner