130 {
131 if (!output) {
132 return SET_ERRNO(ERROR_INVALID_PARAM, "Output stream cannot be NULL");
133 }
134
135 fprintf(output,
136 "# Fish completion script for ascii-chat\n"
137 "# Generated from options registry - DO NOT EDIT MANUALLY\n"
138 "\n"
139 "complete -c ascii-chat -f\n"
140 "\n"
141 "function __fish_ascii_chat_using_mode\n"
142 " set -l cmd (commandline -opc)\n"
143 " for arg in $cmd\n"
144 " if contains -- $arg server client mirror\n"
145 " echo $arg\n"
146 " return 0\n"
147 " end\n"
148 " end\n"
149 " return 1\n"
150 "end\n"
151 "\n"
152 "function __fish_ascii_chat_mode_is\n"
153 " test (string match -q $argv[1] (command __fish_ascii_chat_using_mode))\n"
154 "end\n"
155 "\n"
156 "function __fish_ascii_chat_no_mode\n"
157 " not __fish_ascii_chat_using_mode > /dev/null\n"
158 "end\n"
159 "\n"
160 "# Modes\n"
161 "complete -c ascii-chat -n __fish_ascii_chat_no_mode -a server -d 'Run a video chat server'\n"
162 "complete -c ascii-chat -n __fish_ascii_chat_no_mode -a client -d 'Connect to a video chat server'\n"
163 "complete -c ascii-chat -n __fish_ascii_chat_no_mode -a mirror -d 'View webcam locally without network'\n"
164 "\n");
165
166
167 size_t binary_count = 0;
169
170 fprintf(output, "# Binary-level options (same as 'ascii-chat --help')\n");
171 if (binary_opts) {
172 for (size_t i = 0; i < binary_count; i++) {
173 fish_write_option(output, &binary_opts[i], "");
174 }
175 SAFE_FREE(binary_opts);
176 }
177 fprintf(output, "\n");
178
179
180 size_t server_count = 0;
182
183 fprintf(output, "# Server options (same as 'ascii-chat server --help')\n");
184 if (server_opts) {
185 for (size_t i = 0; i < server_count; i++) {
186 fish_write_option(output, &server_opts[i], "-n '__fish_seen_subcommand_from server'");
187 }
188 SAFE_FREE(server_opts);
189 }
190 fprintf(output, "\n");
191
192
193 size_t client_count = 0;
195
196 fprintf(output, "# Client options (same as 'ascii-chat client --help')\n");
197 if (client_opts) {
198 for (size_t i = 0; i < client_count; i++) {
199 fish_write_option(output, &client_opts[i], "-n '__fish_seen_subcommand_from client'");
200 }
201 SAFE_FREE(client_opts);
202 }
203 fprintf(output, "\n");
204
205
206 size_t mirror_count = 0;
208
209 fprintf(output, "# Mirror options (same as 'ascii-chat mirror --help')\n");
210 if (mirror_opts) {
211 for (size_t i = 0; i < mirror_count; i++) {
212 fish_write_option(output, &mirror_opts[i], "-n '__fish_seen_subcommand_from mirror'");
213 }
214 SAFE_FREE(mirror_opts);
215 }
216 fprintf(output, "\n");
217
218
219 size_t discovery_svc_count = 0;
220 const option_descriptor_t *discovery_svc_opts =
222
223 fprintf(output, "# Discovery-service options (same as 'ascii-chat discovery-service --help')\n");
224 if (discovery_svc_opts) {
225 for (size_t i = 0; i < discovery_svc_count; i++) {
226 fish_write_option(output, &discovery_svc_opts[i], "-n '__fish_seen_subcommand_from discovery-service'");
227 }
228 SAFE_FREE(discovery_svc_opts);
229 }
230
231 return ASCIICHAT_OK;
232}
const option_descriptor_t * options_registry_get_for_display(asciichat_mode_t mode, bool for_binary_help, size_t *num_options)