105 {
106 if (!output) {
107 return SET_ERRNO(ERROR_INVALID_PARAM, "Output stream cannot be NULL");
108 }
109
110 fprintf(output, "#compdef _ascii_chat ascii-chat\n"
111#ifndef NDEBUG
112 "#compdef _ascii_chat build/bin/ascii-chat ./build/bin/ascii-chat\n"
113#endif
114 "# Zsh completion script for ascii-chat\n"
115 "# Generated from options registry - DO NOT EDIT MANUALLY\n"
116 "\n"
117 "_ascii_chat() {\n"
118 " local curcontext=\"$curcontext\" state line\n"
119 " _arguments -C \\\n");
120
121
122 size_t binary_count = 0;
124
125 if (binary_opts) {
126 for (size_t i = 0; i < binary_count; i++) {
127 zsh_write_option(output, &binary_opts[i]);
128 }
129 SAFE_FREE(binary_opts);
130 }
131
132 fprintf(output, " '1:mode:(server client mirror discovery-service)' \\\n"
133 " '*::mode args:_ascii_chat_subcommand'\n"
134 "}\n"
135 "\n"
136 "_ascii_chat_subcommand() {\n"
137 " case $line[1] in\n"
138 " server)\n"
139 " _arguments \\\n");
140
141
142 size_t server_count = 0;
144
145 if (server_opts) {
146 for (size_t i = 0; i < server_count; i++) {
147 zsh_write_option(output, &server_opts[i]);
148 }
149 SAFE_FREE(server_opts);
150 }
151
152 fprintf(output, " && return 0\n"
153 " ;;\n"
154 " client)\n"
155 " _arguments \\\n");
156
157
158 size_t client_count = 0;
160
161 if (client_opts) {
162 for (size_t i = 0; i < client_count; i++) {
163 zsh_write_option(output, &client_opts[i]);
164 }
165 SAFE_FREE(client_opts);
166 }
167
168 fprintf(output, " && return 0\n"
169 " ;;\n"
170 " mirror)\n"
171 " _arguments \\\n");
172
173
174 size_t mirror_count = 0;
176
177 if (mirror_opts) {
178 for (size_t i = 0; i < mirror_count; i++) {
179 zsh_write_option(output, &mirror_opts[i]);
180 }
181 SAFE_FREE(mirror_opts);
182 }
183
184 fprintf(output, " && return 0\n"
185 " ;;\n"
186 " discovery-service)\n"
187 " _arguments \\\n");
188
189
190 size_t discovery_svc_count = 0;
191 const option_descriptor_t *discovery_svc_opts =
193
194 if (discovery_svc_opts) {
195 for (size_t i = 0; i < discovery_svc_count; i++) {
196 zsh_write_option(output, &discovery_svc_opts[i]);
197 }
198 SAFE_FREE(discovery_svc_opts);
199 }
200
201 fprintf(output, " && return 0\n"
202 " ;;\n"
203 " esac\n"
204 "}\n"
205 "\n"
206 "_ascii_chat \"$@\"\n");
207
208 return ASCIICHAT_OK;
209}
const option_descriptor_t * options_registry_get_for_display(asciichat_mode_t mode, bool for_binary_help, size_t *num_options)