Open-source C++ library

Simple CLI

A C++23 command-line parser for type-safe flags, options, commands, aliases, positional arguments, and explicit result-based errors.

Overview

A reusable parsing layer for modern C++ applications.

Simple CLI registers command-line behavior through typed handlers. It supports Boolean flags, several option types, commands with optional parameters, positional inputs, short and long aliases, and custom conversion for user-defined types.

Normal parsing failures are represented through a small Result and Error layer, keeping the public API explicit without relying on exceptions for routine invalid input.

Design

Handler-based argument modeling.

  • Flags, bindable values, and callable commands are modeled as separate handler behaviors.
  • Aliases point to the same logical handler so duplicate use can be detected consistently.
  • Each parse creates a fresh internal handler set while external bindings remain under caller control.
  • Command callbacks are deferred until token parsing and value conversion complete successfully.
Source example

Registering a typed option.

The registration call returns a result immediately, allowing invalid tags or parser configuration to be handled where the option is declared.

example/argumentParser.cppC++
if (auto result = parser.addOption(
    {"-o", "--output"}, output
); !result) {
    std::cout << result.error().message() << std::endl;
    return 1;
}
Current scope

Supported use and known boundaries.

The library can be consumed through traditional headers or C++ modules and is packaged as a CMake static library. It supports separate values and inline --option=value syntax.

The current parser is non-transactional: a failed parse may leave external bindings changed, so callers should reset them before another attempt. The current version also does not implement a dedicated -- end-of-options delimiter.