CLI

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production; see the section bibliography for the reference material consulted while preparing these pages.

Welcome to the CLI reference. It teaches how to build command-line and terminal applications for Windows, macOS and Linux: what a terminal really is, how a program talks to it through POSIX and Win32 interfaces, how to write native command-line programs in C, C++, Swift, Objective-C, .NET, Go, Rust and on the JVM and Kotlin, how to build full-screen terminal user interfaces (TUIs) with Ratatui (in depth), Bubble Tea, Textual, Terminal.Gui, ncurses, FTXUI and other libraries, how to handle prompts, progress output, shells, completions and services, and how to ship the result as signed native binaries and packages. Each of the 33 concept pages explains one idea in detail, with tables of every option, platform differences, pitfalls, examples and a link to the official page each example derives from. The printable Cheat Sheet (PDF) summarises every concept on one A4 page.

This section covers what is specific to native and terminal-facing programs. The repository already documents a lot of command-line material, and that material is linked, never repeated:

Reading map

Pick the path that matches what you are building. The pages are in dependency order inside each group.

  1. One-shot commands. Start with the landscape and stack chooser, then the foundations (terminals, escape sequences, POSIX and Windows), then the page for your language.

  2. Interactive prompts and shells. Add prompts and line editing, progress, colour and rich output and shells and completions.

  3. Full-screen TUIs. Read TUI architecture and concepts, then the library page for your language (the four Ratatui pages are the most detailed).

  4. Shipping. Finish with native binaries, signing and OS trust, packages and installers and testing.

The shelf scenario

Every example belongs to one tool, shelf, a command-line client for the Bookshelf domain used in other sections of this site. It grows with the section:

  • shelf list, shelf add, shelf loan and shelf return are one-shot subcommands, written in each language.

  • shelf repl is an interactive prompt with history and completion.

  • shelf tui is a full-screen catalogue browser with a list of books, a details pane, a loans table and a search box. It is implemented with Ratatui in depth and, more briefly, with Bubble Tea, Textual, Terminal.Gui, ncurses and FTXUI, so the libraries can be compared on the same screen.

  • shelfd is a background service with a local IPC socket, used by the services page.

The scenario is original and not copied from any tutorial.

Version baseline

The section was written against these versions, verified on 25 October 2026. Where a row says not re-verified, no live source or release feed was reachable, and the page keeps the wording of the earlier check without finer claims.

Area Versions

Standards and platforms

POSIX.1-2024 (IEEE Std 1003.1-2024, Open Group Base Specifications Issue 8); glibc 2.44; ncurses 6.6; ECMA-48 5th edition; Unicode UAX #11 revision 46 (Unicode 18.0); .NET 11 is at release candidate 2 and not yet generally available

Rust

Ratatui 0.30.2 (no 1.0 yet), ratatui-core 0.1.2, crossterm 0.29.0, termion 4.0.6, termwiz 0.23.3, tui-realm 4.1.0, ratatui-textarea 0.9.3, color-eyre 0.6.5, clap 4.6.7, indicatif 0.18.6, dialoguer 0.12.0, inquire 0.9.4, rustyline 19.0.0, reedline 0.52.1, insta 1.49.0, cross 0.2.5, dist 0.33.1

Go

Go 1.27.3; Bubble Tea v2.1.0, Bubbles v2.2.1, Lip Gloss v2.0.6, Huh v2.0.3, Glamour v2.0.1, VHS v0.12.1, tview v0.42.0, tcell v3.6.0, Cobra v1.10.2, urfave/cli v3.14.0

Python

Python 3.15.1 (the argparse suggest_on_error default is True since 3.15); Textual 8.2.8, Rich 15.0.0, prompt_toolkit 3.0.53, windows-curses 2.4.2, Click 8.5.0, Typer 0.27.3, PyInstaller 6.22.3, Nuitka 4.3.1, pexpect 4.9.0, pytest-textual-snapshot 1.1.0

.NET

.NET 10 LTS, latest patch 10.0.13; System.CommandLine 2.0.13 (a 3.0.0 preview exists and is not used); Spectre.Console 0.57.2; Terminal.Gui v2.5.0 (repository tui-cs/Terminal.Gui)

C and C++

FTXUI v7.0.3, CLI11 v2.7.2, cxxopts v3.3.1, notcurses v3.0.17, PDCursesMod v4.5.4; Boost 1.92, GNU Readline 8.3, libedit 20260512-3.1 (not re-verified)

Swift and Objective-C

Swift 6.4.1, swift-argument-parser 1.8.2, swift-subprocess 1.0.2, swift-system 1.8.1

JVM, Kotlin and Node.js

Clikt 5.1.0, Mordant 3.1.0, Mosaic 0.18.0, picocli 4.7.7, Lanterna 3.1.5 (3.2.0-alpha1 exists and is not used), JLine 4.4.8, TamboUI 0.6.0; Ink 8.0.0 (React 19.3 or later, Node.js 22 or later), @inquirer/prompts 8.7.4, @clack/prompts 1.8.1, chalk 6.0.1, ora 9.4.1; GraalVM 25 and the Java 22 foreign-function claim (not re-verified)

The pages

Foundations

Page What it covers

The CLI Landscape & Choosing a Stack (central)

The kinds of terminal program, native versus managed runtimes compared, a decision matrix and a decision flow.

Terminals, TTYs & Pseudo-Terminals (central)

Emulator versus shell versus program, the kernel line discipline, canonical and raw mode, termios, PTYs, sessions and job control.

Escape Sequences & Terminal Capabilities (central)

ECMA-48 control functions, colour, cursor, alternate screen, mouse, bracketed paste, hyperlinks, Kitty protocols, terminfo and Unicode width.

POSIX Processes, Signals & I/O (central)

argv and environ, file descriptors, fork, exec and posix_spawn, signals, SIGPIPE, stdio buffering and the Utility Syntax Guidelines.

Windows Console & Processes (central)

Console versus GUI subsystem, the console API versus virtual-terminal sequences, code pages, argv splitting, Ctrl handlers, CreateProcess, job objects and ConPTY.

Cross-Platform Portability

One table of the differences between Windows, macOS, Linux and the BSDs, and the portable abstractions per language.

Native command-line programs by language

Page What it covers

Command-Line Programs in C (central)

main and exit status, getopt, getopt_long, argp, getline, errno, signals, a termios key reader and building on every platform.

Command-Line Programs in C++

CLI11, cxxopts and Boost.Program_options, std::print and std::format, std::filesystem, and CMake with vcpkg and Conan.

Command-Line Tools in Swift (central)

SwiftPM, swift-argument-parser, Foundation.Process and swift-subprocess, signals, Swift on Linux and Windows, and the Static Linux SDK.

Command-Line Tools in Objective-C

The Command Line Tool template, NSProcessInfo, NSUserDefaults arguments, NSTask, GCD signal sources, clang and GNUstep.

.NET Console Applications (central)

The Console class, PosixSignalRegistration, the Generic Host, System.CommandLine 2.0, file-based apps, Native AOT and global tools.

Command-Line Programs in Go

The standard library, urfave/cli v3 and Cobra, golang.org/x/term, signal-aware shutdown and cross-compiling.

Command-Line Programs in Rust

clap derive, error reporting, signals, terminal detection and colour, per-OS directories and cross-compiling.

Command-Line Programs on the JVM & Kotlin

java.io.Console, the source-file launcher, ProcessBuilder, shutdown hooks, startup time, jlink, jpackage, picocli, Clikt and Native Image.

Terminal user interfaces

Page What it covers

TUI Architecture & Concepts (central)

Immediate versus retained mode, the input-update-render loop, cell buffers, The Elm Architecture, the terminal lifecycle and focus.

Ratatui: Getting Started (central)

The 0.30 crate split, templates, ratatui::run, Terminal::draw, Frame and a first catalogue browser.

Ratatui: Layout, Widgets & Styling (central)

Layout, Constraint and Flex, text and styles, every built-in widget and custom widgets.

Ratatui: Events, Async & Application Architecture (central)

crossterm events, the Elm, component and Flux architectures, Tokio, panic hooks, backends and inline viewports.

Ratatui: Testing & Ecosystem

TestBackend, insta snapshots, VHS, third-party widget crates, tui-realm and surviving breaking changes.

Go TUIs with Bubble Tea (central)

Bubble Tea v2, messages and commands, Bubbles, Lip Gloss, Huh, Glamour, testing and VHS.

Python TUIs with Textual, Rich & prompt_toolkit (central)

Rich output, Textual apps, widgets, CSS, workers, screens, testing with Pilot, and prompt_toolkit.

.NET TUIs with Spectre.Console & Terminal.Gui

Spectre.Console widgets, live displays and prompts, and Terminal.Gui v2 views, layout, menus and drivers.

C & C++ TUIs: ncurses, PDCurses & FTXUI

ncurses windows, pads, panels and forms, PDCursesMod on Windows, notcurses and FTXUI.

Other TUI Libraries: JVM, Kotlin, Node.js & Swift

Lanterna, TamboUI, Mosaic, Ink, blessed and SwiftTUI, with requirements and maintenance status.

Interaction, output and integration

Page What it covers

Interactive Prompts & Line Editing

Line editors, prompt libraries, history, completion, password input and building a REPL.

Progress, Colour & Rich Output

Progress bars, spinners, tables, Markdown, colour, terminal width and keeping logs apart from user output.

Shells, Completions & Shell Integration

Completion systems for bash, zsh, fish, PowerShell and Nushell, quoting differences and shell integration.

Long-Running Processes & Services

systemd, launchd, Windows services, single-instance locks, logging and the client plus daemon split.

Accessibility & Internationalization

What screen readers can read, plain modes, 16-colour themes, plural rules, locales, right-to-left text and Unicode normalization.

Shipping

Page What it covers

Native Binaries & Cross-Compilation (central)

Static versus dynamic linking, glibc versus musl, universal binaries, cross-compilation, size and reproducible builds.

Signing, Notarization & OS Trust (central)

codesign, notarytool, Gatekeeper, Authenticode, SmartScreen, checksums, Sigstore and signed repositories.

Native Packages & Installers

deb, rpm, Homebrew, Scoop, winget, Chocolatey, MSI and MSIX, Snap, AppImage, Nix and install scripts.

Testing Terminal Apps & TUIs

Real-PTY testing with Expect and pexpect, screen reading, snapshots, tmux, VHS, asciinema and CI on every platform.

Cheat Sheet (PDF)

A single A4 page summarising every concept of the section.

Choose your page

flowchart TD start["What are you building?"] --> kind{"What kind of program?"} kind -->|"Not sure which language"| landscape["The CLI Landscape and Choosing a Stack"] kind -->|"One-shot command"| lang{"Which language?"} kind -->|"Interactive prompt or REPL"| prompts["Interactive Prompts and Line Editing"] kind -->|"Full-screen TUI"| tui["TUI Architecture and Concepts"] kind -->|"Background service"| services["Long-Running Processes and Services"] lang -->|"C, C++, Objective-C"| clang["C, C++ and Objective-C pages"] lang -->|"Swift, .NET, JVM"| managed["Swift, .NET and JVM pages"] lang -->|"Go, Rust"| gorust["Go and Rust pages"] tui --> libs{"Which library?"} libs -->|"Rust"| ratatui["Ratatui pages"] libs -->|"Go, Python, .NET"| others["Bubble Tea, Textual, Terminal.Gui"] libs -->|"C, C++"| ncurses["ncurses and FTXUI"] landscape --> lang clang --> ship["Native binaries, signing, packages"] managed --> ship gorust --> ship prompts --> ship ratatui --> ship others --> ship ncurses --> ship services --> ship ship --> test["Testing terminal apps and TUIs"]

Bibliography

Every source used to write this section is listed below, grouped by area and linked to its official website. Each page also lists the subset it used under its own References heading. Links that point to community conventions rather than standards say so. The bibliography for the material on designing CLIs for people and AI agents is at Building CLIs for AI Agents.

Linux, glibc and GNU

Further sources cited by the pages

These sources are cited under the References heading of individual pages and are not in the lists above.