A lightweight C++ command-line argument parser.
- Simple API
- Boolean, string, and integer arguments
- Fixed-length string support
- Built-in help message (
--help) - No external dependencies
#include "cppargparse.hpp"
#include <iostream>
int main(int argc, const char* argv[]) {
bool flag = false;
char str[10];
int num = 0;
cpp_arg_parse::submit::Boolean("--flag", "Example flag", &flag);
cpp_arg_parse::submit::StringN("--str", "Example string", str, 9);
cpp_arg_parse::submit::Integer("--num", "Example number", &num);
cpp_arg_parse::parse::help();
cpp_arg_parse::parse::args(argc, argv);
std::cout << flag << " " << str << " " << num << std::endl;
}submit::Boolean("--flag", "Description", &bool_var);submit::Integer("--num", "Description", &int_var);submit::String("--str", "Description", buffer);submit::StringN("--str", "Description", buffer, max_length);max_length is max number of characters excluding null terminator
cpp_arg_parse::parse::help();makeg++ cppargparse.cpp file.cpp -o app- Uses raw pointers (
void*) internally - No type safety guarantees
- Buffer sizes must be managed by the user
- Argument order is not preserved in help output
- See LICENSE for details