<commit_before>#include "opt.h"

static typedef struct CorcOptElement
{
    int short_opt;
    CorkString *long_opt;
    CorkString *help_opt;
    int flags;
} CorcOptElement;

CorcOpt *
corcopt_init(void)
{
    CorcOpt *co;

    if ((co = malloc(sizeof(CorcOpt))) == NULL)
        return NULL;

    co->args = corclist_create();
    return co;
}

void
corcopt_fini(CorcOpt *co)
{ }

void
corcopt_help(CorcOpt *co)
{
    void *t;
    CorcOptElement *coe;

    CORCLIST_FOREACH(co->args, t)
    {
        coe = (CorcOptElement *)t;

        printf("Usage: %s\n");
        printf("%s or %s: %s\n", coe->short_opt->string,
                                 coe->long_opt->string,
                                 coe->help_text->string);
    }
}

bool
corcopt_add(CorcOpt *co,
            const int short_opt,
            const char *long_opt,
            const char *help_text,
            void (*cb)(CorcOpt *co, CorcString *optarg),
            const int flags)
{
    CorcOptElement *coe;

    if ((coe = malloc(sizeof(CorcOptElement))) == NULL)
        return false;

    coe->short_opt = short_opt;
    coe->long_opt  = corcstr(long_opt);
    coe->help_text = corcstr(help_text);
    coe->flags     = flags;

    corclist_append(co->opts, coe);
    return true;
}<commit_msg>Simplify CorcOptElement<commit_after>#include "opt.h"

static typedef struct CorcOptElement
{
    int short_opt, flags;
    CorcString *long_opt, *help_text;
} CorcOptElement;

CorcOpt *
corcopt_init(void)
{
    CorcOpt *co;

    if ((co = malloc(sizeof(CorcOpt))) == NULL)
        return NULL;

    co->args = corclist_create();
    return co;
}

void
corcopt_fini(CorcOpt *co)
{ }

void
corcopt_help(CorcOpt *co)
{
    void *t;
    CorcOptElement *coe;

    CORCLIST_FOREACH(co->args, t)
    {
        coe = (CorcOptElement *)t;

        printf("Usage: %s\n");
        printf("%s or %s: %s\n", coe->short_opt->string,
                                 coe->long_opt->string,
                                 coe->help_text->string);
    }
}

bool
corcopt_add(CorcOpt *co,
            const int short_opt,
            const char *long_opt,
            const char *help_text,
            void (*cb)(CorcOpt *co, CorcString *optarg),
            const int flags)
{
    CorcOptElement *coe;

    if ((coe = malloc(sizeof(CorcOptElement))) == NULL)
        return false;

    coe->short_opt = short_opt;
    coe->long_opt  = corcstr(long_opt);
    coe->help_text = corcstr(help_text);
    coe->cb        = cb;
    coe->flags     = flags;

    corclist_append(co->opts, coe);
    return true;
}

void
corcopt_parse(CorcOpt *co, int argc, char *argv[])
{
    CorcOptElement *coe;
    CorcString *optarg;
    void *t;

    CORCLIST_FOREACH(co->args, t)
    {
        coe = (CorkOptElement *)t;
    }
}
{'fraction_non_alphanumeric': 0.12851985559566786, 'fraction_numerical': 0.0, 'mean_word_length': 2.2183507549361208, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3331161', 'n_tokens_mistral': 1041, 'n_tokens_neox': 988, 'n_words': 205}