Skip to content

TechEverythingTikTok/CPPArgParse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cppargparse

A lightweight C++ command-line argument parser.

Features

  • Simple API
  • Boolean, string, and integer arguments
  • Fixed-length string support
  • Built-in help message (--help)
  • No external dependencies

Example

#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;
}

Usage

Boolean

submit::Boolean("--flag", "Description", &bool_var);

Integer

submit::Integer("--num", "Description", &int_var);

String

submit::String("--str", "Description", buffer);

StringN

submit::StringN("--str", "Description", buffer, max_length);

max_length is max number of characters excluding null terminator

Help Output

cpp_arg_parse::parse::help();

Build

make
g++ cppargparse.cpp file.cpp -o app

Notes

  • 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

License

  • See LICENSE for details

About

Very limited and basic argument parser for C++

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors