Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. C/C++
  3. argparse

argparse

MITC++v3.2

A single-header argument parsing library for modern C++17 applications.

GitHubGitHub
3.5k stars308 forks0 contributors

What is argparse?

argparse is a single-header argument parsing library for modern C++ that simplifies handling command-line arguments in applications. It provides a declarative API to define positional arguments, optional flags, subcommands, and complex parsing logic, replacing manual argc/argv processing with a robust, type-safe solution.

Target Audience

C++ developers building command-line tools, utilities, or applications that require sophisticated argument parsing, especially those using C++17 or newer standards.

Value Proposition

Developers choose argparse for its ease of use, modern C++ design, and comprehensive feature set—including subcommands, custom actions, and automatic help—all in a single header with no external dependencies.

Overview

Argument Parser for Modern C++

Use Cases

Best For

  • Building command-line tools with subcommands (like git)
  • Parsing complex argument structures with mutual exclusivity
  • Applications requiring automatic help generation and usage formatting
  • Tools that need to handle positional and optional arguments flexibly
  • Projects wanting a lightweight, header-only argument parser
  • C++17/20 codebases seeking modern, type-safe argument handling

Not Ideal For

  • Projects constrained to C++14 or earlier compiler toolchains
  • Applications where immediate program exit on --help/--version is unacceptable for proper resource cleanup
  • Tools with only a handful of static, hardcoded arguments that don't benefit from dynamic parsing features

Pros & Cons

Pros

Single-Header Simplicity

Just include argparse.hpp for instant integration, eliminating build system complexity and external dependencies, as highlighted in the Quick Start section.

Modern C++ Type Safety

Leverages C++17 features like scanning to numeric types and std::optional via .present(), ensuring compile-time checks and reducing runtime errors, as shown in argument handling examples.

Comprehensive Feature Set

Supports subcommands, mutually exclusive groups, parent parsers, and custom actions, matching the flexibility of Python's argparse, detailed in sections like Subcommands and Advanced Parsing.

Automatic Help Generation

Generates well-formatted usage messages with descriptions and epilogs, customizable via methods like set_usage_max_line_width and add_group, demonstrated in the help formatting examples.

Cons

Destructor-Skipping Exit

Default --help and --version actions exit the program immediately without calling destructors, which the README admits can bypass resource cleanup in the Default Arguments section.

Non-Copyable Design

ArgumentParser copy and move constructors are deleted since v3.0, restricting usage patterns and requiring setup in a single scope, as noted in the Developer Notes on copying and moving.

C++17 Mandate

Requires C++17 or newer, making it incompatible with legacy codebases or environments with older compiler toolchains, as stated in the Supported Toolchains table.

Frequently Asked Questions

Quick Stats

Stars3,508
Forks308
Contributors0
Open Issues66
Last commit1 year ago
CreatedSince 2019

Tags

#parsing#library#cplusplus-17#cpp17#mit-license#argument-parser#cplusplus#cli#cross-platform#single-header#command-line#header-only

Built With

C
C++17

Included in

C/C++70.6k
Auto-fetched 1 day ago

Related Projects

FTXUIFTXUI

:computer: C++ Functional Terminal User Interface. :heart:

Stars10,462
Forks607
Last commit4 days ago
cxxoptscxxopts

Lightweight C++ command line option parser

Stars4,794
Forks650
Last commit11 days ago
CLI11CLI11

CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.

Stars4,376
Forks457
Last commit15 days ago
linenoiselinenoise

A small self-contained alternative to readline and libedit

Stars4,320
Forks736
Last commit2 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub