12 best Practices for developing a command-line tool

Source: Internet
Author: User

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:

    1. Good help commands are essential (great helps is essential)
    2. Prefer to use the optional system instead of parameters (Prefer flags to args)
    3. Clear the current version (typically--version/-v) (what version am I on?)
    4. Focus on stream processing (input and output streams and redirects) (Mind the Streams)
    5. Handling Errors (Handle things going wrong)
    6. Yan Control (be fancy!)
    7. Try to hint (Prompt if you can)
    8. Using tables (use tables)
    9. The only thing that's going to break (be speedy)
    10. Encourage open source contribution code (encourage contributions)
    11. Clear Sub-command (be clear about subcommands)
    12. Follow the XDG specification (follow Xdg-spec)

Original: Factor CLI Apps

12 best Practices for developing a command-line tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.