Examples Overview
The repository ships a set of focused programs under
examples/.
Each one is small enough to copy into a project, but specific enough to answer
"how do I do this with cli20?" without digging through tests.
Example Order
- Simple API
The smallest useful typed-schema CLI: help, a flag, an option, and a required positional. - Subcommands
Nested commands with their own help output and behavior. - Validation Parse-time checks for numbers, names, and filesystem arguments.
- Relations Schema-level relationships such as groups, conflicts, and depends_on.
- Bind Write values directly into existing variables.
- Callback Entry Point Fill application state during parsing, then call the real entry point.
- Advanced Lower-level composition with explicit conversion, validation, and packing steps.
- Custom Action
Full struct-based action definition with
accepts_input,after_type, andstorage_type. - Git A command-heavy CLI inspired by clap's git example, including nested subcommands.
- Compiler Wrapper
Short-cluster flags, negatable key-value options, and
std::mapstorage withinsert_or_assign. - Distribution and Platform Examples Single-header usage, C++20 modules, and the Windows Unicode sample used by CI.
- Env Fallback Populate options from environment variables with the same conversion and validation pipeline.
Building
cmake -B build
cmake --build build
Each source file becomes an executable with the same base name under build/examples/.