Overview
args.h provides a header-only argument manager intended for modular C codebases. Arguments are declared with ARGUMENT in any source file, registered automatically, then processed in three explicit stages: parsing, validation, and actions.
Feature Highlights
- Distributed argument declarations with constructor-based registration.
- Automatic help generation.
- Dependency/conflict/subset relationships between arguments.
- Automatic validation of required arguments and relation rules.
- Typed parsing helpers via ARG_PARSER family.
- Validation and general callbacks with flexible execution policies.
- Deterministic cross-file ordering for help, validate, and action stages.
Quick Start
#define ARGS_IMPLEMENTATION
#include "args.h"
static bool my_flag;
static void print_my_flag(void)
{
printf("Hello from my_flag\n");
}
.set = &my_flag,
.action_callback = print_my_flag,
.help = "Enable my flag",
.lopt = "my-flag",
.opt = 'f',
};
int main(int argc, char **argv) {
return 1;
printf("My flag is %s\n", my_flag ? "enabled!" : "disabled!");
return 0;
}
@ ARG_CALLBACK_IF_SET
Definition args.h:438
#define ARGUMENT(name)
Creates and registers a new argument object.
Definition args.h:146
bool args_validate(void)
Validates argument schema rules and user-provided combinations.
void args_actions(void)
Executes action callbacks for arguments matching action phase rules.
bool args_parse(int argc, char *argv[])
Parses command line arguments and runs parse-phase relations.
Docs Navigation