Mikhail Romanko a2c0c2afad
All checks were successful
CI / build-and-analyze (push) Successful in 53s
Prevent name mangling in C++
2026-08-18 10:41:56 +03:00
2026-08-17 15:06:08 +03:00
2026-08-17 15:06:08 +03:00
2026-08-17 15:06:08 +03:00
2026-08-18 10:41:56 +03:00
2026-08-17 15:06:08 +03:00
2026-08-17 15:06:08 +03:00
2026-08-17 15:06:08 +03:00
2026-08-17 15:06:08 +03:00
2026-08-17 15:06:08 +03:00
2026-08-17 15:06:08 +03:00
2026-08-17 15:06:08 +03:00

CgeArgs - CLI argument parsing

TODO

Usage Example

#include "CgeArgs.h"
#include <stdio.h>

int main(int argc, char **argv) {
    int boolOption = 0, intOption = 0;
    const char *strOption = "default";
    float floatOption = 0;
    double doubleOption = 0;
    int i;

    CgeArgs args[] = {
        {'a', "a", CGE_ARGS_BOOL, &boolOption},
        {'b', "b", CGE_ARGS_INT, &intOption},
        {'c', "c", CGE_ARGS_STRING, &strOption},
        {'d', "d", CGE_ARGS_FLOAT, &floatOption},
        {'e', "e", CGE_ARGS_DOUBLE, &doubleOption},
    };

    i = CgeArgsParse(args, sizeof(args) / sizeof(CgeArgs), argc, argv);
    if (i != -1) {
        printf("bool: %d\n", boolOption);
        printf("int: %d\n", intOption);
        printf("str: %s\n", strOption);
        printf("float: %f\n", floatOption);
        printf("double: %lf\n", doubleOption);

        for (; i < argc; i++) {
            printf("free arg: %s\n", argv[i]);
        }
    } else {
        printf("unknown arg\n");
    }
    return 0;
}

License

0BSD - a permissive license with no attribution required.

Description
C CLI Argument Parsing
Readme 0BSD 30 KiB
Languages
C 89.1%
CMake 10.9%