A lightweight, header-only C library that brings Python's argparse functionality to C. Define your command-line arguments, parse them effortlessly, and map them back to variables with minimal boilerplate.
Perfect for CLI tools, utilities, and any C project that needs clean argument parsing without external dependencies.
argtable.c aims to provide a simple, intuitive API for parsing command-line arguments in C programs. Inspired by Python's argparse module, it allows you to define expected arguments and automatically parse them from argv, handling the mapping between command-line inputs and your program's variables.
You need:
- A C compiler (GCC, Clang, or MSVC)
- Standard C library
Currently, the source files contain standalone test programs. To compile and test:
For cargparse.c:
gcc src/cargparse.c -o cargparse
./cargparse --foo bar --baz quxFor getargs.c:
gcc src/getargs.c -o getargs
./getargs <table_size> --arg1 value1 --arg2 value2The library aims to fulfill these core requirements:
- Define arguments - Declare expected command-line arguments with their types and constraints
- Pass arguments - Accept arguments via standard
argc/argv - Parse arguments - Automatically parse and validate inputs
- Map to variables - Map parsed values back to accessible C variables
- โ
Basic
--arg valueparsing - ๐ Argument type validation (integers, strings, booleans)
- ๐ Optional vs required arguments
- ๐ Short flags (
-halongside--help)
Once complete, the lib can be used for any type of project that needs a CLI interface.
MIT License - see LICENSE file for details.