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.
Scope and what this section links to instead
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:
-
The Building CLIs for AI Agents sub-section covers designing a CLI that people and AI agents can both use: output formats, exit codes, errors, configuration, TUIs versus CLIs, frameworks, packaging and testing. Its own bibliography is at the Building CLIs for AI Agents bibliography.
-
Language and framework command-line pages stay where they are: Node.js CLI tools, Quarkus command mode, command-line PHP, Rust I/O, processes and environment, C program structure, the Go Reference, the Swift Reference and the Flask, Django, Pyramid and NestJS command pages listed under Related Guides in the navigation.
-
Windows desktop applications with a graphical interface are in Windows Apps, and macOS distribution is further covered in macOS distribution outside the App Store.
Reading map
Pick the path that matches what you are building. The pages are in dependency order inside each group.
-
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.
-
Interactive prompts and shells. Add prompts and line editing, progress, colour and rich output and shells and completions.
-
Full-screen TUIs. Read TUI architecture and concepts, then the library page for your language (the four Ratatui pages are the most detailed).
-
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 loanandshelf returnare one-shot subcommands, written in each language. -
shelf replis an interactive prompt with history and completion. -
shelf tuiis 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. -
shelfdis 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 |
.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 |
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. |
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. |
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. |
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. |
The standard library, urfave/cli v3 and Cobra, golang.org/x/term, signal-aware shutdown and cross-compiling. |
|
clap derive, error reporting, signals, terminal detection and colour, per-OS directories and cross-compiling. |
|
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. |
crossterm events, the Elm, component and Flux architectures, Tokio, panic hooks, backends and inline viewports. |
|
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. |
Rich output, Textual apps, widgets, CSS, workers, screens, testing with Pilot, and prompt_toolkit. |
|
Spectre.Console widgets, live displays and prompts, and Terminal.Gui v2 views, layout, menus and drivers. |
|
ncurses windows, pads, panels and forms, PDCursesMod on Windows, notcurses and FTXUI. |
|
Lanterna, TamboUI, Mosaic, Ink, blessed and SwiftTUI, with requirements and maintenance status. |
Interaction, output and integration
| Page | What it covers |
|---|---|
Line editors, prompt libraries, history, completion, password input and building a REPL. |
|
Progress bars, spinners, tables, Markdown, colour, terminal width and keeping logs apart from user output. |
|
Completion systems for bash, zsh, fish, PowerShell and Nushell, quoting differences and shell integration. |
|
systemd, launchd, Windows services, single-instance locks, logging and the client plus daemon split. |
|
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. |
deb, rpm, Homebrew, Scoop, winget, Chocolatey, MSI and MSIX, Snap, AppImage, Nix and install scripts. |
|
Real-PTY testing with Expect and pexpect, screen reading, snapshots, tmux, VHS, asciinema and CI on every platform. |
|
A single A4 page summarising every concept of the section. |
Choose your page
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.
Standards and specifications
-
Community conventions, not standards: OSC 8 hyperlinks, synchronized output (mode 2026), truecolor, NO_COLOR, FORCE_COLOR, CLICOLOR
Linux, glibc and GNU
-
The GNU C Library manual (Program Arguments, Getopt, Argp, Low-Level Terminal Interface, Job Control and Signal Handling)
-
Linux man-pages (termios(3), pty(7), signal(7), console_codes(4)); mirror at kernel.org
Windows
Apple
-
Notarizing macOS software before distribution, Customizing the notarization workflow, Resolving common notarization issues
-
Hardened Runtime, Creating distribution-signed code for the Mac
-
CommandLine, ProcessInfo, Creating a standalone Swift package with Xcode
-
Homebrew Formula Cookbook, Bottles, Taps, How to create and maintain a tap, Acceptable Formulae
Languages and CLI libraries
-
Swift: Getting started with SwiftPM, Swift on Linux, Swift on Windows, Static Linux SDK, swift-argument-parser, swift-subprocess, swift-system
-
.NET: System.CommandLine, Console, Native AOT, file-based apps, global tools, What’s new in the .NET 10 SDK
-
C and C++: CLI11, cxxopts, Boost.Program_options
-
Go: flag, os/signal, golang.org/x/term, urfave/cli, Cobra
-
Rust: Command Line Applications in Rust, clap, indicatif, dialoguer, inquire, rustyline, reedline, color-eyre, dist (cargo-dist), cross
-
Python: argparse, What’s New in Python 3.15, curses, Curses Programming with Python, windows-curses, Click, Typer, PyInstaller, Nuitka
-
JVM and Kotlin: picocli, JLine, java.io.Console, Clikt, Mordant, kotlinx-cli, Kotlin/Native, GraalVM Native Image
-
Node.js prompts and output: @inquirer/prompts, @clack/prompts, chalk, ora
TUI libraries
-
Ratatui: ratatui.rs (concepts, tutorials, recipes, templates, showcase, highlights and FAQ), ratatui, ratatui-core, ratatui-widgets, templates
-
crossterm, termion, termwiz, tui-realm, ratatui-textarea, insta
-
Charm: charm.land, Bubble Tea, Bubbles, Lip Gloss, Huh, Glamour, teatest, VHS
-
Textual (guide, widget gallery and testing), Rich, prompt_toolkit, pytest-textual-snapshot
Shells, distribution, testing and accessibility
-
zsh completion system, fish completions, Nushell custom completions
-
Debian Policy, nfpm, Snapcraft classic confinement, AppImage, Nix, musl
-
Community guides, not specifications: Command Line Interface Guidelines, 12 Factor CLI Apps (a personal blog post)
Further sources cited by the pages
These sources are cited under the References heading of individual pages and are not in the lists above.
-
Microsoft Learn
-
docs.rs crate documentation
-
pubs.opengroup.org
-
GitHub projects
-
ratatui.rs
-
textual.textualize.io
-
spectreconsole.net
-
tui-cs.github.io
-
Apple developer documentation
-
man7.org
-
sourceware.org
-
Oracle Java documentation
-
invisible-island.net
-
OpenJDK
-
rich.readthedocs.io
-
cppreference.com
-
Python documentation
-
Swift Package Index
-
CMake
-
Rust documentation
-
Go package documentation
-
Kotlin documentation
-
Meson
-
Node.js
-
freedesktop.org
-
Sigstore
-
Go
-
nfpm.goreleaser.com
-
python-prompt-toolkit.readthedocs.io
-
Apple support
-
wiki.debian.org
-
GNU
-
Unicode
-
blog.rust-lang.org
-
central.sonatype.com
-
Clang
-
cldr.unicode.org
-
cli.urfave.org
-
cobra.dev
-
crates.io
-
curl.se
-
dnf.readthedocs.io
-
docs.conan.io
-
docs.gradle.org
-
fmt.dev
-
gnustep.github.io
-
kislyuk.github.io
-
FreeBSD manual
-
nix.dev
-
Project Fluent
-
questionary.readthedocs.io
-
rpm-software-management.github.io
-
rust-lang.github.io
-
slsa.dev
-
snapcraft.io
-
terminal-wg.pages.freedesktop.org
-
GNU Readline
-
tqdm.github.io
-
www.npmjs.com