ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
options/builder/internal.h
Go to the documentation of this file.
1
12#pragma once
13
15#include <ascii-chat/common.h>
16#include <stdbool.h>
17#include <stddef.h>
18
19// Initial capacities for dynamic arrays
20#define INITIAL_DESCRIPTOR_CAPACITY 32
21#define INITIAL_DEPENDENCY_CAPACITY 16
22#define INITIAL_POSITIONAL_ARG_CAPACITY 8
23#define INITIAL_OWNED_STRINGS_CAPACITY 32
24
28typedef struct {
29 // Check if option value differs from default
30 bool (*is_set)(const void *field, const option_descriptor_t *desc);
31 // Apply environment variable and set defaults
32 void (*apply_env)(void *field, const char *env_value, const option_descriptor_t *desc);
33 // Parse CLI argument value
34 asciichat_error_t (*apply_cli)(void *field, const char *opt_value, const option_descriptor_t *desc);
35 // Format value for help text placeholder (e.g., "NUM", "STR")
36 void (*format_help_placeholder)(char *buf, size_t bufsize);
38
39// Handler registry - indexed by option_type_t (defined in handlers.c)
41#define NUM_OPTION_TYPES 6 // BOOL, INT, STRING, DOUBLE, CALLBACK, ACTION
42
43// Helper functions from various modules (can be called across modules)
45int format_option_default_value_str(const option_descriptor_t *desc, char *buf, size_t bufsize);
46bool option_applies_to_mode(const option_descriptor_t *desc, asciichat_mode_t mode, bool for_binary_help);
47
48// Capacity management (in builder.c)
53
54// Internal lookup (in lifecycle.c)
55const option_descriptor_t *find_option(const options_config_t *config, const char *long_name);
56bool is_option_set(const options_config_t *config, const void *options_struct, const char *option_name);
Options builder API for flexible command-line option configuration.
⚙️ Common definitions, error codes, macros, and types shared throughout the application
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
asciichat_mode_t
Mode type for options parsing.
const char * get_option_help_placeholder_str(const option_descriptor_t *desc)
Get help placeholder string for an option type.
Definition builder.c:43
void ensure_owned_strings_capacity(options_builder_t *builder)
bool is_option_set(const options_config_t *config, const void *options_struct, const char *option_name)
Check if an option is set (has non-default value)
Definition builder.c:356
void ensure_positional_arg_capacity(options_builder_t *builder)
Grow positional arg array if needed.
Definition builder.c:247
const option_builder_handler_t g_builder_handlers[]
const option_descriptor_t * find_option(const options_config_t *config, const char *long_name)
Find option descriptor by long name.
Definition builder.c:344
int format_option_default_value_str(const option_descriptor_t *desc, char *buf, size_t bufsize)
Format option default value as a string.
Definition builder.c:83
void ensure_dependency_capacity(options_builder_t *builder)
Grow dependency array if needed.
Definition builder.c:230
bool option_applies_to_mode(const option_descriptor_t *desc, asciichat_mode_t mode, bool for_binary_help)
Check if an option applies to a specific mode using bitmask.
Definition builder.c:177
void ensure_descriptor_capacity(options_builder_t *builder)
Grow descriptor array if needed.
Definition builder.c:213
bool is_set
ClangTool/LibTooling compatibility shim for stdbool.h.
#define bool
Definition stdbool.h:61
Type handler for builder operations.
Option descriptor.
Definition builder.h:241
Options builder.
Definition builder.h:441
Options configuration.
Definition builder.h:401