Comment: A well-designed command-line application is a productive tool, and this article describes 12 best practices for developing command-line tools
The CLI is a great way to build a product, and unlike a Web app, it takes less time and is more powerful. Using the Web, you can do whatever the developer writes, using the CLI, you can easily mix multiple tools together to perform more advanced tasks that require more expertise to use, but still apply to administrative tasks, advanced user tasks, or developer products.
In Heroku, we present a method called "12-factor app", which is a set of principles designed to make good Web applications that are easy to maintain. We have also built a CLI framework called OCLIF, which is designed to follow these principles to build a great CLI application using node.
In this spirit, when building the next CLI, keep in mind the following 12 factors:
- Good help commands are essential (great helps is essential)
- Prefer to use the optional system instead of parameters (Prefer flags to args)
- Clear the current version (typically--version/-v) (what version am I on?)
- Focus on stream processing (input and output streams and redirects) (Mind the Streams)
- Handling Errors (Handle things going wrong)
- Yan Control (be fancy!)
- Try to hint (Prompt if you can)
- Using tables (use tables)
- The only thing that's going to break (be speedy)
- Encourage open source contribution code (encourage contributions)
- Clear Sub-command (be clear about subcommands)
- Follow the XDG specification (follow Xdg-spec)
Original: Factor CLI Apps
12 best Practices for developing a command-line tool