ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
presets.c
Go to the documentation of this file.
1
6
7/* Storage capacities in elements; text buffers include the terminating NUL. */
8#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF1_BUFFER_SIZE 256
9#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF2_BUFFER_SIZE 256
10#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF3_BUFFER_SIZE 256
11#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF4_BUFFER_SIZE 256
12#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF5_BUFFER_SIZE 256
13
19#include <ascii-chat/common.h>
20#include <libplatform/terminal.h>
22#include <ascii-chat/log/log.h>
24#include <ascii-chat/discovery/strings.h> // Added for dynamic session string generation
25
26// ============================================================================
27// NOTE: All static parser functions and group helper functions have been
28// moved to lib/options/registry.c and are no longer needed here.
29// The registry is now the single source of truth for all option definitions.
30// ============================================================================
31
39 (void)b;
40 // Kept for backward compatibility but no longer used
41}
42
43// ============================================================================
44// Webcam & Display Options Helper (Client + Mirror)
45// ============================================================================
46
47// ============================================================================
48// Unified Options Preset
49// ============================================================================
50
58options_config_t *options_preset_unified(const char *program_name, const char *description) {
60 if (!b) {
61 SET_ERRNO(ERROR_MEMORY, "Failed to create options builder");
62 return NULL;
63 }
64
65 b->program_name = program_name ? program_name : "ascii-chat";
66 b->description = description ? description : "Video chat in your terminal";
67
68 // Add ALL options from registry (binary + all modes)
70 if (err != ASCIICHAT_OK) {
72 SET_ERRNO(err, "Failed to add all options to builder");
73 return NULL;
74 }
75
76 // Add positional arguments for each mode
77 // These allow parsing of positional arguments like "192.168.1.1" for client mode
78 // and "[bind-address]" for server mode
79
80 // Generate random session strings for examples
81 // Use static buffers so they persist after the function returns
82 static char session_buf1[SESSION_STRING_BUFFER_SIZE];
83 static char session_buf2[SESSION_STRING_BUFFER_SIZE];
84 static char session_buf3[SESSION_STRING_BUFFER_SIZE];
85 static char session_buf4[SESSION_STRING_BUFFER_SIZE];
86 static char session_buf5[SESSION_STRING_BUFFER_SIZE];
87 static char session_buf6[SESSION_STRING_BUFFER_SIZE];
88 static char session_buf7[SESSION_STRING_BUFFER_SIZE];
89 static char session_buf8[SESSION_STRING_BUFFER_SIZE];
90 static char session_buf9[SESSION_STRING_BUFFER_SIZE];
91 static char session_buf10[SESSION_STRING_BUFFER_SIZE];
92
93 // Fallback strings if generation fails
94 char *example_session_string1 = "adjective-noun-noun";
95 char *example_session_string2 = "adjective-noun-noun";
96 char *example_session_string3 = "adjective-noun-noun";
97 char *example_session_string4 = "adjective-noun-noun";
98 char *example_session_string5 = "adjective-noun-noun";
99 char *example_session_string6 = "adjective-noun-noun";
100 char *example_session_string7 = "adjective-noun-noun";
101 char *example_session_string8 = "adjective-noun-noun";
102 char *example_session_string9 = "adjective-noun-noun";
103 char *example_session_string10 = "adjective-noun-noun";
104
105 // Generate session strings for examples (sodium_init called as needed by acds_string_generate)
106 acds_string_generate(session_buf1, sizeof(session_buf1));
107 if (session_buf1[0] != '\0') {
108 example_session_string1 = session_buf1;
109 }
110 acds_string_generate(session_buf2, sizeof(session_buf2));
111 if (session_buf2[0] != '\0') {
112 example_session_string2 = session_buf2;
113 }
114 acds_string_generate(session_buf3, sizeof(session_buf3));
115 if (session_buf3[0] != '\0') {
116 example_session_string3 = session_buf3;
117 }
118 acds_string_generate(session_buf4, sizeof(session_buf4));
119 if (session_buf4[0] != '\0') {
120 example_session_string4 = session_buf4;
121 }
122 acds_string_generate(session_buf5, sizeof(session_buf5));
123 if (session_buf5[0] != '\0') {
124 example_session_string5 = session_buf5;
125 }
126 acds_string_generate(session_buf6, sizeof(session_buf6));
127 if (session_buf6[0] != '\0') {
128 example_session_string6 = session_buf6;
129 }
130 acds_string_generate(session_buf7, sizeof(session_buf7));
131 if (session_buf7[0] != '\0') {
132 example_session_string7 = session_buf7;
133 }
134 acds_string_generate(session_buf8, sizeof(session_buf8));
135 if (session_buf8[0] != '\0') {
136 example_session_string8 = session_buf8;
137 }
138 acds_string_generate(session_buf9, sizeof(session_buf9));
139 if (session_buf9[0] != '\0') {
140 example_session_string9 = session_buf9;
141 }
142 acds_string_generate(session_buf10, sizeof(session_buf10));
143 if (session_buf10[0] != '\0') {
144 example_session_string10 = session_buf10;
145 }
146
147 // Build session string examples dynamically for discovery mode
148 // These appear at the beginning of the examples section, right after "start new session"
149 static char example_buf1[SESSION_STRING_BUFFER_SIZE];
150 static char example_buf2[SESSION_STRING_BUFFER_SIZE];
151 static char example_buf3[SESSION_STRING_BUFFER_SIZE];
152 static char example_buf4[SESSION_STRING_BUFFER_SIZE];
153 static char example_buf5[SESSION_STRING_BUFFER_SIZE];
154 static char example_buf6[SESSION_STRING_BUFFER_SIZE];
155 static char example_buf7[SESSION_STRING_BUFFER_SIZE];
156 static char example_buf8[SESSION_STRING_BUFFER_SIZE];
157 static char example_buf9[SESSION_STRING_BUFFER_SIZE];
158 static char example_buf10[SESSION_STRING_BUFFER_SIZE];
159
160 safe_snprintf(example_buf1, sizeof(example_buf1), "%s", example_session_string1);
161 safe_snprintf(example_buf2, sizeof(example_buf2), "%s", example_session_string2);
162 safe_snprintf(example_buf3, sizeof(example_buf3), "%s", example_session_string3);
163 safe_snprintf(example_buf4, sizeof(example_buf4), "%s", example_session_string4);
164 safe_snprintf(example_buf5, sizeof(example_buf5), "%s", example_session_string5);
165 safe_snprintf(example_buf6, sizeof(example_buf6), "%s", example_session_string6);
166 safe_snprintf(example_buf7, sizeof(example_buf7), "%s", example_session_string7);
167 safe_snprintf(example_buf8, sizeof(example_buf8), "%s", example_session_string8);
168 safe_snprintf(example_buf9, sizeof(example_buf9), "%s", example_session_string9);
169 safe_snprintf(example_buf10, sizeof(example_buf10), "%s", example_session_string10);
170
171 // Client mode: [address] - can be IP, hostname, hostname:port, or WebSocket URL
172 static const char *client_examples[] = {"localhost",
173 "ascii-chat.com",
174 "0.0.0.0",
175 "::",
176 "192.168.1.1:8080",
177 "[2001:db8::42]:27224",
178 "233.27.48.203:27224",
179 "62fb:759e:2bce:21d7:9e5d:13f8:3c11:5084:27224",
180 "ws://example.com:8080",
181 "wss://secure.example.com:443"};
182 // Discovery mode: [session-string] - session string or empty to start new session
183 // Use simple static examples for positional arguments section (dynamic strings shown in examples section)
184 static const char *discovery_examples[] = {"(empty/unset) start new session. generates a session string to give someone to connect to you.", (const char *)example_buf7, (const char *)example_buf8,
185 (const char *)example_buf9, (const char *)example_buf10};
186 options_builder_add_positional(b, "session-string", "(optional) Random three words in format adjective-noun-noun that connect you to a call.", false, "POSITIONAL ARGUMENTS", discovery_examples,
187 ARRAY_SIZE(discovery_examples), OPTION_MODE_DISCOVERY, parse_client_address);
188
189 // Server and Discovery Service modes: [bind-address] [bind-address] - can be IP or hostname, up to 2 for IPv4/IPv6
190 static const char *server_examples[] = {
191 "localhost", "ascii-chat.com", "0.0.0.0", "::", "234.50.188.236", "9631:54e7:5b5c:80dc:0f62:1f01:7ccf:5512", "105.137.19.11 3a08:7276:ccb4:7b31:e934:5330:9b3a:9598", "::1 192.168.1.100"};
192 options_builder_add_positional(b, "bind-address", "(optional) 0-2 addresses for a server to bind to, one IPv4 and the other IPv6.", false, "POSITIONAL ARGUMENTS", server_examples,
194
195 options_builder_add_positional(b, "address", "(optional) Server address for client to connect to.", false, "POSITIONAL ARGUMENTS", client_examples, ARRAY_SIZE(client_examples), OPTION_MODE_CLIENT,
197
198 // Mirror mode: [file|url] - file path or URL to stream
199 static const char *mirror_media_examples[] = {"/path/to/video.mp4", "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "https://example.com/stream.m3u8"};
200 options_builder_add_positional(b, "file|url",
201 "(optional) Media file path or URL to stream. If omitted, uses webcam. "
202 "Cannot be combined with --file or --url.",
203 false, "POSITIONAL ARGUMENTS", mirror_media_examples, ARRAY_SIZE(mirror_media_examples), OPTION_MODE_MIRROR, parse_mirror_media);
204
205 // Add usage lines for all modes
206 options_builder_add_usage(b, NULL, NULL, true, "Start a new session (share the session string)");
207 options_builder_add_usage(b, NULL, "<session-string>", true, "Join an existing session");
208 options_builder_add_usage(b, NULL, "<mode>", true, "Run in a specific mode");
209 options_builder_add_usage(b, "mcp-server", "[--transport http|stdio] [--server] [bind-address] [bind-address]", true,
210 "MCP rendering tools (stdio locally, HTTP with --transport http, default port 27228)");
211 options_builder_add_example(b, OPTION_MODE_MCP_SERVER, "", "Local MCP tools over stdio", false);
212 options_builder_add_example(b, OPTION_MODE_MCP_SERVER, "--transport http --address 127.0.0.1 --port 27228", "Local MCP tools over Streamable HTTP", false);
213 options_builder_add_usage(b, "server", "[bind-address] [bind-address]", true, "Start server (can specify 0-2 bind addresses, one IPv4 and the other IPv6)");
214 options_builder_add_usage(b, "client", "[address]", true, "Connect to server (defaults to localhost:27224)");
215 options_builder_add_usage(b, "mirror", "[file|url]", true, "View local webcam or media file or URL as ASCII art");
216 options_builder_add_usage(b, "discovery-service", "[bind-address] [bind-address]", true, "Start discovery service (can specify 0-2 bind addresses, one IPv4 and the other IPv6)");
217 options_builder_add_usage(b, NULL, "[mode] --help", false, "Show help for a specific mode");
218
219 // Add examples for binary-level help and discovery mode
220 options_builder_add_example(b, OPTION_MODE_BINARY, NULL, "Start new session (share the session string)", false);
221 options_builder_add_example(b, OPTION_MODE_BINARY, example_buf1, "Join a session using the session string", true);
222
223 // Build combined examples with session string + flags
224 static char combined_buf1[OPTIONS_CONFIG_PRESETS_COMBINED_BUF1_BUFFER_SIZE];
225 static char combined_buf2[OPTIONS_CONFIG_PRESETS_COMBINED_BUF2_BUFFER_SIZE];
226 static char combined_buf3[OPTIONS_CONFIG_PRESETS_COMBINED_BUF3_BUFFER_SIZE];
227 static char combined_buf4[OPTIONS_CONFIG_PRESETS_COMBINED_BUF4_BUFFER_SIZE];
228 static char combined_buf5[OPTIONS_CONFIG_PRESETS_COMBINED_BUF5_BUFFER_SIZE];
229 safe_snprintf(combined_buf1, sizeof(combined_buf1), "%s --file video.mp4", example_buf3);
230 safe_snprintf(combined_buf2, sizeof(combined_buf2), "%s --url 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'", example_buf4);
231 safe_snprintf(combined_buf3, sizeof(combined_buf3), "%s -f -", example_buf5);
232 safe_snprintf(combined_buf4, sizeof(combined_buf4), "%s --palette-chars '@%%#*+=-:. '", example_buf6);
233 safe_snprintf(combined_buf5, sizeof(combined_buf5), "%s --discovery-service wss://discovery.ascii.chat", example_buf2);
234
235 options_builder_add_example(b, OPTION_MODE_BINARY, combined_buf1, "Join session and stream from local video file", false);
236 options_builder_add_example(b, OPTION_MODE_BINARY, combined_buf2, "Join session and stream from YouTube video", false);
237 options_builder_add_example(b, OPTION_MODE_BINARY, combined_buf3, "Join session and stream media from stdin", false);
238 options_builder_add_example(b, OPTION_MODE_BINARY, combined_buf4, "Join session with custom ASCII palette characters", false);
239 options_builder_add_example(b, OPTION_MODE_BINARY, combined_buf5, "Join session via custom discovery server", false);
240
241 // Add examples for server-like modes (server + discovery-service)
242 options_builder_add_example(b, OPTION_MODE_SERVER_LIKE, NULL, "Start on localhost (127.0.0.1 and ::1)", false);
243 options_builder_add_example(b, OPTION_MODE_SERVER_LIKE, "0.0.0.0", "Start on all IPv4 interfaces", false);
244 options_builder_add_example(b, OPTION_MODE_SERVER_LIKE, "0.0.0.0 ::", "Start on all IPv4 and IPv6 interfaces (dual-stack)", false);
245 options_builder_add_example(b, OPTION_MODE_SERVER_LIKE, "--port 8080", "Start on custom port", false);
246
247 // Server-specific examples
248 options_builder_add_example(b, OPTION_MODE_SERVER, "--key ~/.ssh/id_ed25519 --discovery", "Start with identity key and discovery registration", false);
249
250 // Add examples for client-like modes (client + mirror)
251 options_builder_add_example(b, OPTION_MODE_CLIENT_LIKE, "--url 'https://youtu.be/7ynHVGCehoM'", "Stream from YouTube URL (also supports RTSP, HTTP, and HTTPS URLs)", false);
252 options_builder_add_example(b, OPTION_MODE_CLIENT_LIKE, "--url 'https://www.twitch.tv/ludwig'", "Stream Ludwig from videogames on Twitch", false);
253 options_builder_add_example(b, OPTION_MODE_CLIENT_LIKE, "-f video.mp4", "Stream from local video file", false);
254 options_builder_add_example(b, OPTION_MODE_CLIENT_LIKE, "--palette-chars '@%#*+=-:. '", "Custom palette characters to use. UTF-8 is allowed.", false);
256 "Print ascii art for --snapshot-delay's value of seconds then print the last frame and exit. "
257 "In snapshot mode, --width, --height, and --color are NOT autodetected when piping stdin in or redirecting "
258 "output.",
259 false);
260 options_builder_add_example(b, OPTION_MODE_CLIENT_LIKE, "--color-filter cyan --palette cool", "Apply cyan color filter and cool palette", false);
261
262 // Client-specific examples
263 options_builder_add_example(b, OPTION_MODE_CLIENT, "example.com", "Connect to remote server", false);
264 options_builder_add_example(b, OPTION_MODE_CLIENT, "example.com:8080", "Connect to remote server on custom port", false);
265 options_builder_add_example(b, OPTION_MODE_CLIENT, "--color-mode mono --render-mode half-block --width 120", "Connect with custom display options", false);
266
267 // Mirror-specific examples (unique to mirror mode)
268 options_builder_add_example(b, OPTION_MODE_MIRROR, NULL, "View the webcam or files or URLs as ASCII art. Like client mode but without network connectivity or a server.", false);
269 options_builder_add_example(b, OPTION_MODE_MIRROR, "--color-mode mono", "View webcam in black and white", false);
270 options_builder_add_example(b, OPTION_MODE_MIRROR, "--color-filter green", "View webcam with green monochromatic color filter", false);
271 options_builder_add_example(b, OPTION_MODE_MIRROR, "--matrix --color-filter rainbow", "Matrix rain effect with rainbow colors cycling over 3.5s", false);
272 options_builder_add_example(b, OPTION_MODE_MIRROR, "--file '-'", "Stream media from stdin (cat file.gif | ascii-chat mirror -f '-')", false);
273 options_builder_add_example_utility(b, OPTION_MODE_MIRROR, "cat video.avi | ascii-chat mirror -f '-' -l -s 00:30", "Stream .avi from stdin, looped, seeking to 00:30", true);
274 options_builder_add_example(b, OPTION_MODE_MIRROR, "--file video.mov --seek 22:10", "Start playback at exactly 22:10 (also works with --url)", false);
275 options_builder_add_example(b, OPTION_MODE_MIRROR, "-f 'https://youtu.be/LS9W8SO-Two' -S -D 0 -s 5:12", "Print a single frame from a YouTube video at exactly 5:12 and exit", false);
276 options_builder_add_example(b, OPTION_MODE_MIRROR, "-S -D 0 | tee frame.txt | pbcopy", "Capture single ASCII frame to clipboard (macOS) and file", false);
277 options_builder_add_example_utility(b, OPTION_MODE_MIRROR, "pbpaste | cat -", "View ASCII frame from clipboard (macOS)", true);
278
279 // Discovery-service specific examples
280 options_builder_add_example(b, OPTION_MODE_DISCOVERY_SVC, "--require-server-identity --require-client-identity", "Enforce identity verification for all parties", false);
281
282 // Add mode descriptions
283 options_builder_add_mode(b, "default",
284 "When the ascii-chat binary is used without a mode, it operates as either client or server automatically and "
285 "uses the discovery-service to make peer connections with session strings");
286 options_builder_add_mode(b, "server", "Run as multi-client video chat server");
287 options_builder_add_mode(b, "client", "Run as video chat client (connect to server)");
288 options_builder_add_mode(b, "mirror", "View local media as ASCII art (no server)");
289 options_builder_add_mode(b, "discovery-service", "Secure P2P session signalling");
290 options_builder_add_mode(b, "mcp-server", "MCP media rendering tools");
291 options_builder_add_mode(b, "api-server", "HTTP image-to-ASCII API");
292
293 // Add custom help sections for interactive modes (client, mirror, and discovery)
294 options_builder_add_custom_section(b, "KEYBINDINGS",
295 "Available in ascii-chat client, mirror, and discovery modes. "
296 "While rendering, press '?' to display a keyboard shortcuts help menu showing:\n"
297 " - Available keybindings (?, Space, arrows, m, c, f, r, -)\n"
298 " - Press - to toggle the FPS counter (always visible in keyboard help).\n"
299 " - Current settings (volume, color mode, audio status, etc.)",
301
302 // Add environment variables section (all modes)
303 options_builder_add_custom_section(b, "ENVIRONMENT",
304 "All command-line flags that accept values have corresponding environment variables.\n"
305 " Format: ASCII_CHAT_<FLAG_NAME> where FLAG_NAME is uppercase with hyphens replaced by underscores\n"
306 " Example: --color-filter maps to ASCII_CHAT_COLOR_FILTER\n"
307 "\n"
308 " Configuration precedence (lowest to highest):\n"
309 " 1. Config file values (~/.ascii-chat/config.toml)\n"
310 " 2. Environment variables (ASCII_CHAT_*)\n"
311 " 3. Command-line flags (--flag-name)\n"
312 "\n"
313 " Additional environment variables are documented in the ascii-chat(1) man page.",
315
316 // Add common dependencies (these will be validated after parsing)
317 // Note: Dependencies are validated at runtime, so we add them here for documentation
318
319 // ============================================================================
320 // Media Source Conflicts
321 // ============================================================================
322 // URL conflicts: --url cannot be used with --file or --loop
323 options_builder_add_dependency_conflicts(b, "url", "file", "Option --url cannot be used with --file (--url takes priority)");
324 options_builder_add_dependency_conflicts(b, "url", "loop", "Option --url cannot be used with --loop (network streams cannot be looped)");
325
326 // ============================================================================
327 // Encryption & Authentication Conflicts
328 // ============================================================================
329 // Reject contradictory CLI requests before initializing transport security.
330 options_builder_add_dependency_conflicts(b, "no-encrypt", "encrypt", "Cannot use --no-encrypt with --encrypt");
331
332 // Authentication material conflicts with explicitly disabling authentication.
333 options_builder_add_dependency_conflicts(b, "no-auth", "key", "Cannot use --no-auth with --key (key requires authentication)");
334 options_builder_add_dependency_conflicts(b, "no-auth", "password", "Cannot use --no-auth with --password (password requires authentication)");
335 options_builder_add_dependency_conflicts(b, "no-auth", "client-keys", "Cannot use --no-auth with --client-keys (key list requires authentication)");
336 options_builder_add_dependency_conflicts(b, "no-auth", "server-key", "Cannot use --no-auth with --server-key (verification requires authentication)");
337
338 // Identity and verification keys can be combined, including with --no-encrypt.
339
340 // ============================================================================
341 // Compression Conflicts
342 // ============================================================================
343 // Cannot use --no-compress with --compression-level
344 options_builder_add_dependency_conflicts(b, "no-compress", "compression-level", "Cannot use --no-compress with --compression-level");
345
346 // ============================================================================
347 // Audio Encoding Conflicts
348 // ============================================================================
349 // Cannot use both --encode-audio and --no-encode-audio
350 options_builder_add_dependency_conflicts(b, "encode-audio", "no-encode-audio", "Cannot use both --encode-audio and --no-encode-audio");
351
352 // ============================================================================
353 // Display & Screen Conflicts
354 // ============================================================================
355 options_builder_add_dependency_conflicts(b, "waveform", "matrix", "Option --waveform cannot be used with --matrix");
356 options_builder_add_dependency_conflicts(b, "fft", "matrix", "Option --fft cannot be used with --matrix");
357 options_builder_add_dependency_conflicts(b, "waveform", "fft", "Options --waveform and --fft cannot be used together");
358 options_builder_add_dependency_conflicts(b, "waveform", "stretch", "Option --waveform cannot be used with --stretch");
359 options_builder_add_dependency_conflicts(b, "fft", "stretch", "Option --fft cannot be used with --stretch");
360
361 // ============================================================================
362 // Requirements (dependencies that must be satisfied)
363 // ============================================================================
364 // --snapshot-delay requires --snapshot
365 options_builder_add_dependency_requires(b, "snapshot-delay", "snapshot", "Option --snapshot-delay requires --snapshot");
366
367 // --loop requires --file (can't loop network streams)
368 options_builder_add_dependency_requires(b, "loop", "file", "Option --loop requires --file");
369
370 const options_config_t *config = options_builder_build(b);
372 return config;
373}
Action option callbacks for ascii-chat.
#define SET_ERRNO(code,...)
Options builder API for flexible command-line option configuration.
void options_builder_add_usage(options_builder_t *builder, const char *mode, const char *positional, bool show_options, const char *description)
Add usage line descriptor.
void options_builder_add_example(options_builder_t *builder, uint32_t mode_bitmask, const char *args, const char *description, bool owns_args)
Add example descriptor.
void options_builder_add_dependency_requires(options_builder_t *builder, const char *option_name, const char *depends_on, const char *error_message)
Add dependency: if option_name is set, depends_on must be set.
void options_builder_add_positional(options_builder_t *builder, const char *name, const char *help_text, bool required, const char *section_heading, const char **examples, size_t num_examples, option_mode_bitmask_t mode_bitmask, int(*parse_fn)(const char *arg, void *config, char **remaining, int num_remaining, char **error_msg))
Add positional argument descriptor.
void options_builder_add_dependency_conflicts(options_builder_t *builder, const char *option_name, const char *conflicts_with, const char *error_message)
Add anti-dependency: if option_name is set, conflicts_with must NOT be set.
void options_builder_add_mode(options_builder_t *builder, const char *name, const char *description)
Add mode descriptor.
void options_builder_add_custom_section(options_builder_t *builder, const char *heading, const char *content, option_mode_bitmask_t mode_bitmask)
Add a custom help section.
void options_builder_destroy(options_builder_t *builder)
Free options builder.
options_config_t * options_builder_build(options_builder_t *builder)
Build immutable options config.
void options_builder_add_example_utility(options_builder_t *builder, uint32_t mode_bitmask, const char *args, const char *description, bool is_utility_command)
Add an example with utility command support.
options_builder_t * options_builder_create(size_t struct_size)
Mutable owner used to assemble option descriptors, dependencies, help sections, and examples before b...
asciichat_error_t acds_string_generate(char *output, size_t output_size)
Generate random session string.
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ERROR_MEMORY
Definition error_codes.h:55
@ ASCIICHAT_OK
Definition error_codes.h:50
#define OPTION_MODE_CLIENT_LIKE
Definition options.h:953
struct options_state options_t
Immutable, RCU-published snapshot of the application's runtime configuration.
#define OPTION_MODE_SERVER_LIKE
Mode group macros for examples.
Definition options.h:952
@ OPTION_MODE_ALL
All modes + binary.
Definition options.h:943
@ OPTION_MODE_BINARY
Binary-level options (parsed before mode detection).
Definition options.h:942
@ OPTION_MODE_CLIENT
Client mode (bit 1).
Definition options.h:936
@ OPTION_MODE_DISCOVERY
Discovery mode (bit 4).
Definition options.h:939
@ OPTION_MODE_SERVER
Server mode (bit 0).
Definition options.h:935
@ OPTION_MODE_MIRROR
Mirror mode (bit 2).
Definition options.h:937
@ OPTION_MODE_MCP_SERVER
Definition options.h:940
@ OPTION_MODE_DISCOVERY_SVC
Discovery server mode (bit 3).
Definition options.h:938
⚙️ Common definitions, error codes, macros, and types shared throughout the application
Central registry of all command-line options with mode applicability.
📝 Logging API with multiple log levels and terminal output control
TOML configuration file support for ascii-chat.
⚙️ Unified options parsing system for ascii-chat with builder pattern and lock-free access
ASCII Palette Management for Video-to-ASCII Conversion.
int parse_server_bind_address(const char *arg, void *config, char **remaining, int num_remaining, char **error_msg)
Parse server bind address positional argument.
Definition parsers.c:497
int parse_mirror_media(const char *arg, void *config, char **remaining, int num_remaining, char **error_msg)
Parse mirror mode positional argument (file path or URL).
Definition parsers.c:806
int parse_client_address(const char *arg, void *config, char **remaining, int num_remaining, char **error_msg)
Parse client address positional argument.
Definition parsers.c:617
Custom option parsers for enum types.
#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF1_BUFFER_SIZE
Definition presets.c:8
void options_builder_add_logging_group(options_builder_t *b)
Add binary-level logging options to a builder.
Definition presets.c:38
#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF4_BUFFER_SIZE
Definition presets.c:11
#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF2_BUFFER_SIZE
Definition presets.c:9
#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF3_BUFFER_SIZE
Definition presets.c:10
#define OPTIONS_CONFIG_PRESETS_COMBINED_BUF5_BUFFER_SIZE
Definition presets.c:12
options_config_t * options_preset_unified(const char *program_name, const char *description)
Build unified options config with ALL options (binary + all modes).
Definition presets.c:58
asciichat_error_t options_registry_add_all_to_builder(options_builder_t *builder)
Add all options from registry to builder.
Definition public_api.c:168
#define SESSION_STRING_BUFFER_SIZE
Immutable parsing tables produced from an options builder.
Definition builder.h:459
const char * program_name
Definition builder.h:489
const char * description
Definition builder.h:490
Immutable parsing tables produced from an options builder.
Definition builder.h:415