Single-header C++ library for defining CLI options, subcommands, validators, and help text. It targets C++11 and later with no dependencies beyond the standard library.
Overview
CLI11 is a C++ library for parsing command-line arguments in applications ranging from small utilities to large scientific tools. It ships as a header-only package, often distributed as one combined header file, and avoids external dependencies beyond C++11.
Developers declare an application object, attach options and flags with typed bindings, nest subcommands, and rely on macros or helpers to parse argc/argv with consistent exit codes for help and errors. Validators can enforce paths, numeric ranges, or custom rules, and configuration can be loaded from INI or similar formats with optional environment variable input.
The design supports option groups, positional parameters, repeating flags, standard `--` separators, and formatter customization for help output. Unicode path notes and optional precompiled library builds address compile-time and platform concerns.
It is compatible with Linux, macOS, and Windows and documents comparisons to other C++ parsers such as Boost Program Options, TCLAP, and cxxopts without positioning itself as a drop-in for any one commercial product.
Key features
- Header-only single-file distribution
- Subcommands and option groups
- Custom validators and transformers
- INI-style configuration files
- Environment variable inputs
- Configurable help formatters
- Optional precompiled build mode
- C++11 baseline compiler support
Use cases
- Adding CLIs to C++ applications
- Nested subcommand programs
- Physics or HPC tool front-ends
- Frameworks embedding CLI11 App types
- Projects needing portable option parsing