Skip to content

LaundryLabs/argtable.c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

argtable.c

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.

Overview

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.

Current Status: Ongoing

Compilation

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 qux

For getargs.c:

gcc src/getargs.c -o getargs
./getargs <table_size> --arg1 value1 --arg2 value2

Requirements & Goals

The library aims to fulfill these core requirements:

  1. Define arguments - Declare expected command-line arguments with their types and constraints
  2. Pass arguments - Accept arguments via standard argc/argv
  3. Parse arguments - Automatically parse and validate inputs
  4. Map to variables - Map parsed values back to accessible C variables

Features (Planned)

  • โœ… Basic --arg value parsing
  • ๐Ÿ”„ Argument type validation (integers, strings, booleans)
  • ๐Ÿ”„ Optional vs required arguments
  • ๐Ÿ”„ Short flags (-h alongside --help)

Use Cases

Once complete, the lib can be used for any type of project that needs a CLI interface.

License

MIT License - see LICENSE file for details.


About

A lightweight implementation of argparse (python library for creating CLIs) in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages