Why CLIs?

CLI applications live in an interesting space, where human-computer interaction naturally blends with automation and programming.

Command-line interfaces are often defined as just that: text-based interfaces or APIs. This makes some sense, as CLI are well useable for humans to input commands and for machine-to-machine automation and scripting. It could be a utilitarian script performing a single action. Or a major application meant to run continuously as a service.

The textual interface crosses architectural paradigms, programming languages, and operating systems. CLI applications are a rather specific area. In many ways close to GUI/desktop applications, with a specific lifecycle. In other ways, CLI applications greatly benefit from being aware of and sometimes implementing current trends in the cloud and DevOps.

CLI application could be a massive ecosystem on its own. With hundreds of commands and options, complex integrations or 3rd party plugins. Or it could be a companion application to another product or a single-purpose utility.

Command-line interfaces are with us for decades. They accumulated layers of practices and rules but also evolved together with the ecosystems built around them.

Introduction

This document should act as a best practices showcase and reference for anyone working on CLI applications or tooling.


There are 3 main sections, all born out of frustration when working on CLIs:

  1. Designing a CLI: outlining common topics, patterns and pitfalls.
  2. How-to guides: a collection of tips and tricks for tackling specific problems.
  3. Glossary of CLI-related terms and concepts

Contents

  1. Design

    1. CLI application lifecycle
    2. CLI Help pages
    3. Collecting analytics
    4. Colors and formatting in the output
    5. Configuration
    6. Debugging
    7. Distribution and Installation
      1. CLI distribution and installation
      2. Self-executing installation scripts
      3. Auto-updating CLI applications
    8. Exit codes
    9. Messaging
    10. Networking
    11. Performance
    12. Security considerations
    13. Versioning CLI applications
  2. Glossary

    1. List of CLI frameworks
    2. man page
    3. POSIX
    4. Terminal Pagers
  3. How tos

    1. How to code sign CLI executables?
    2. How to implement shell autocomplete for your CLI application?