Argument creation and registration macros.
Use ARGUMENT to declare and register new arguments. Each argument is an instance of argument, which has fields for storage, callbacks, schema rules, and ordering controls that you can initialize.
Requirement And Visibility | |
| enum | arg_requirement { ARG_OPTIONAL , ARG_REQUIRED , ARG_HIDDEN , ARG_SOMETIME } |
| Requirement policy for argument::arg_req. More... | |
Parameter Modes | |
| enum | arg_parameter { ARG_PARAM_NONE , ARG_PARAM_REQUIRED , ARG_PARAM_OPTIONAL } |
| Parameter requirement for argument::param_req. More... | |
Callback Stages | |
| bool | args_parse (int argc, char *argv[]) |
| Parses command line arguments and runs parse-phase relations. | |
| 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. | |
Creating New Arguments | |
| #define | ARGUMENT(name) |
| Creates and registers a new argument object. | |
Data Structures | |
| struct | argument |
| Declarative schema object for one CLI argument. More... | |
| #define ARGUMENT | ( | name | ) |
Creates and registers a new argument object.
Use this macro at file scope. It declares argument _arg_<name>, wires constructor-based registration, then leaves a second declaration target for designated initialization.
| name | Unique argument identifier used in generated symbol names. |
main. | enum arg_requirement |
Requirement policy for argument::arg_req.
| enum arg_parameter |
Parameter requirement for argument::param_req.
getopt usage. | Enumerator | |
|---|---|
| ARG_PARAM_NONE | Argument is a flag, does not take a parameter. |
| ARG_PARAM_REQUIRED | argument::parse_callback receives non-NULL |
| ARG_PARAM_OPTIONAL | argument::parse_callback may receive NULL |
| bool args_parse | ( | int | argc, |
| char * | argv[] ) |
Parses command line arguments and runs parse-phase relations.
For each user-provided option, the parser resolves the matching argument and calls argument::parse_callback when available. Parse-time dependency/conflict relations are enforced immediately. Duplicate-argument detection applies only when argument::set is non-NULL, though keep in mind it is implicitly allocated for most features.
*set == true. | true | Parse succeeded for all encountered options. |
| false | At least one user-facing parse error occurred. |
| bool args_validate | ( | void | ) |
Validates argument schema rules and user-provided combinations.
This stage enforces required-argument rules, non-parse relation phases, and executes argument::validate_callback according to argument::validate_phase.
| true | All checks passed. |
| false | One or more constraints failed. |
| void args_actions | ( | void | ) |
Executes action callbacks for arguments matching action phase rules.
true.