CLI
Command-Line Interfaces
CLI is a thing that many of us love a lot. But CLI is as good as we make them be, obviously. Here are some links to the best practices:
- Minimal safe Bash script template, a nice and sane “framework” for small scripts
- 12 Factor CLI Apps from authors of The Twelve-Factor App (Heroku). Yep, some of the factors are so-so. Bot the intent itself is good. TLDR:
- Great help
- Flags instead of args
- Version info
- “stdout for output, stderr for messages”
- Error handling
- Colors plus
--no-color
- “Prompt if you can” (interactivity)
- “Use tables”
- “Be speedy”
- “Encourage contributions” (“Plugins, COC, Open Source”. Meh)
- “Be clear about subcommands”
- “Follow XDG-spec” (!)
Also, it will be nice to add an /asciinema to your tool’s documentation.
Use the libraries, Luke
Implementation of the proper CLI is a though work. Hopefully, there are some shortcuts in this way. One just needs to remember about them.
- optparse-applicative (/haskell/optparse-applicative) for /Haskell
- Click (/python/click) for /Python