<commit_before>#include "ucmd_internal.h"

const char *ucOpt_get_name(ucOpt *p) {
    assert(p);
    return p->name;
}

const char *ucOpt_get_desc(ucOpt *p) {
    assert(p);
    return p->desc;
}

ucBool ucOpt_is_required(ucOpt *p) {
    assert(p);
    return p->is_required;
}

void ucOpt_send_help(ucOpt *p, ucCmdLine *cmd, const char *prefix) {
    static const char *required_format = "%s%s: %s";
    static const char *optional_format = "%s[%s]: %s";
    const char *format = ucOpt_is_required(p) 
        ? required_format 
        : optional_format;
    ucCmdLine_respond(cmd, ucCmdLine_format_response(
        cmd,
        format,
        prefix,
        ucOpt_get_name(p),
        ucOpt_get_desc(p)
    ));
}

ucOpt *ucOpt_init(ucOpt *p, const char *name, const char *desc, ucBool is_required) {
    if (NULL == p) return NULL;
    p->name = name;
    p->desc = desc;
    p->is_required = is_required;
    return p;
}<commit_msg>Assert that option pointer is valid in init.<commit_after>#include "ucmd_internal.h"

const char *ucOpt_get_name(ucOpt *p) {
    assert(p);
    return p->name;
}

const char *ucOpt_get_desc(ucOpt *p) {
    assert(p);
    return p->desc;
}

ucBool ucOpt_is_required(ucOpt *p) {
    assert(p);
    return p->is_required;
}

void ucOpt_send_help(ucOpt *p, ucCmdLine *cmd, const char *prefix) {
    static const char *required_format = "%s%s: %s";
    static const char *optional_format = "%s[%s]: %s";
    const char *format = ucOpt_is_required(p) 
        ? required_format 
        : optional_format;
    ucCmdLine_respond(cmd, ucCmdLine_format_response(
        cmd,
        format,
        prefix,
        ucOpt_get_name(p),
        ucOpt_get_desc(p)
    ));
}

ucOpt *ucOpt_init(ucOpt *p, const char *name, const char *desc, ucBool is_required) {
    assert(p);
    p->name = name;
    p->desc = desc;
    p->is_required = is_required;
    return p;
}
{'fraction_non_alphanumeric': 0.1273784355179704, 'fraction_numerical': 0.0, 'mean_word_length': 3.0448717948717947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6111236', 'n_tokens_mistral': 717, 'n_tokens_neox': 693, 'n_words': 161}