A minimalistic C library for intuitive command line argument parsing. Designed for simplicity, built for functionality.
Report Bug
·
Request a Feature
·
Example Code
- Intuitive Parsing
- Flag Support
- Positional Argument Support
- Auto-generating Help Menu
- Error Handling
- Lightweight and Single Header-only
cclarg is built to simplify the process of command line argument parsing. No need to wrestle with parsing yourself. Incorporate the library and let it handle the intricacies for you
int main(int argc, char *argv[]) {
parse_args(argc, argv, ...);
...
}Supporting both short and long flag formats, cclarg is flexible to your needs. Whether you prefer -h or --help, or even attaching values directly like -f=filename and --file=filename or even -f filename and --file filename , the library has got you covered.
Flag flags[] = {
{"-h", "--help", "Show help menu", ...},
{"-f", "--file", "Specify file", ...}
};Beyond flags, cclarg allows capturing position-based arguments with ease. Whether it's a filename, an operation, or a series of inputs, positionals can be defined to capture them.
Positional positionals[] = {
{"filename", "Name of the file", ...}
};One of cclarg's helpful features is the automated help menu, designed (roughly) in line with GNU standards. With just a function call, get a help menu tailored to your flags and positionals.
if (flags[HELP_FLAG].is_set) {
print_help(...);
}Errors are a part of life. With cclarg parsing returns clear error codes for invalid flags, missing values, or unexpected arguments.
With a focus on simplicity, cclarg is a header-only library. No need for weird installations or additional dependencies.
#include "cclarg.h"Cclarg was designed with a very simple goal in mind, a extremly light and intuitive command line argument parser. To keep it this way, many features you may find in larger libraries aren't here.
If you find a feature absolutly nessasary for command line development that I've missed, please request it as a feature.
