198 if (argc <= 0 || argv ==
nullptr) {
199 result.
error =
"Invalid argv provided";
206 bool passthrough =
false;
207 for (
int i = 1; i < argc; ++i) {
208 char* current = argv[i];
209 absl::string_view token(current);
218 if (absl::StartsWith(token,
"--help=")) {
219 std::string target(token.substr(7));
220 if (!target.empty()) {
227 if (token ==
"--help" || token ==
"-h") {
228 if (i + 1 < argc && argv[i + 1][0] !=
'-') {
237 if (token ==
"--version" || token ==
"-v") {
243 if (token ==
"--list-commands" || token ==
"--list") {
249 if (token ==
"--export-schemas" || token ==
"--export_schemas") {
255 if (token ==
"--self-test" || token ==
"--selftest") {
261 if (token ==
"--tui" || token ==
"--interactive") {
262 absl::SetFlag(&FLAGS_tui,
true);
267 if (token ==
"--quiet" || token ==
"-q") {
268 absl::SetFlag(&FLAGS_quiet,
true);
271 if (absl::StartsWith(token,
"--quiet=")) {
272 std::string value(token.substr(8));
273 absl::SetFlag(&FLAGS_quiet, value ==
"true" || value ==
"1");
278 if (absl::StartsWith(token,
"--rom=")) {
279 absl::SetFlag(&FLAGS_rom, std::string(token.substr(6)));
282 if (token ==
"--rom") {
284 result.
error =
"--rom flag requires a value";
287 absl::SetFlag(&FLAGS_rom, std::string(argv[++i]));
292 if (absl::StartsWith(token,
"--ai_provider=") ||
293 absl::StartsWith(token,
"--ai-provider=")) {
294 size_t eq_pos = token.find(
'=');
295 absl::SetFlag(&FLAGS_ai_provider,
296 std::string(token.substr(eq_pos + 1)));
299 if (token ==
"--ai_provider" || token ==
"--ai-provider") {
301 result.
error =
"--ai-provider flag requires a value";
304 absl::SetFlag(&FLAGS_ai_provider, std::string(argv[++i]));
308 if (absl::StartsWith(token,
"--ai_model=") ||
309 absl::StartsWith(token,
"--ai-model=")) {
310 size_t eq_pos = token.find(
'=');
311 absl::SetFlag(&FLAGS_ai_model, std::string(token.substr(eq_pos + 1)));
314 if (token ==
"--ai_model" || token ==
"--ai-model") {
316 result.
error =
"--ai-model flag requires a value";
319 absl::SetFlag(&FLAGS_ai_model, std::string(argv[++i]));
323 if (absl::StartsWith(token,
"--gemini_api_key=") ||
324 absl::StartsWith(token,
"--gemini-api-key=")) {
325 size_t eq_pos = token.find(
'=');
326 absl::SetFlag(&FLAGS_gemini_api_key,
327 std::string(token.substr(eq_pos + 1)));
330 if (token ==
"--gemini_api_key" || token ==
"--gemini-api-key") {
332 result.
error =
"--gemini-api-key flag requires a value";
335 absl::SetFlag(&FLAGS_gemini_api_key, std::string(argv[++i]));
339 if (absl::StartsWith(token,
"--anthropic_api_key=") ||
340 absl::StartsWith(token,
"--anthropic-api-key=")) {
341 size_t eq_pos = token.find(
'=');
342 absl::SetFlag(&FLAGS_anthropic_api_key,
343 std::string(token.substr(eq_pos + 1)));
346 if (token ==
"--anthropic_api_key" || token ==
"--anthropic-api-key") {
348 result.
error =
"--anthropic-api-key flag requires a value";
351 absl::SetFlag(&FLAGS_anthropic_api_key, std::string(argv[++i]));
355 if (absl::StartsWith(token,
"--gui_server_address=") ||
356 absl::StartsWith(token,
"--gui-server-address=")) {
357 size_t eq_pos = token.find(
'=');
358 absl::SetFlag(&FLAGS_gui_server_address,
359 std::string(token.substr(eq_pos + 1)));
362 if (token ==
"--gui_server_address" || token ==
"--gui-server-address") {
364 result.
error =
"--gui-server-address flag requires a value";
367 absl::SetFlag(&FLAGS_gui_server_address, std::string(argv[++i]));
371 if (absl::StartsWith(token,
"--ollama_host=") ||
372 absl::StartsWith(token,
"--ollama-host=")) {
373 size_t eq_pos = token.find(
'=');
374 absl::SetFlag(&FLAGS_ollama_host,
375 std::string(token.substr(eq_pos + 1)));
378 if (token ==
"--ollama_host" || token ==
"--ollama-host") {
380 result.
error =
"--ollama-host flag requires a value";
383 absl::SetFlag(&FLAGS_ollama_host, std::string(argv[++i]));
387 if (absl::StartsWith(token,
"--prompt_version=") ||
388 absl::StartsWith(token,
"--prompt-version=")) {
389 size_t eq_pos = token.find(
'=');
390 absl::SetFlag(&FLAGS_prompt_version,
391 std::string(token.substr(eq_pos + 1)));
394 if (token ==
"--prompt_version" || token ==
"--prompt-version") {
396 result.
error =
"--prompt-version flag requires a value";
399 absl::SetFlag(&FLAGS_prompt_version, std::string(argv[++i]));
403 if (absl::StartsWith(token,
"--use_function_calling=") ||
404 absl::StartsWith(token,
"--use-function-calling=")) {
405 size_t eq_pos = token.find(
'=');
406 std::string value(token.substr(eq_pos + 1));
407 absl::SetFlag(&FLAGS_use_function_calling,
408 value ==
"true" || value ==
"1");
411 if (token ==
"--use_function_calling" ||
412 token ==
"--use-function-calling") {
414 result.
error =
"--use-function-calling flag requires a value";
417 std::string value(argv[++i]);
418 absl::SetFlag(&FLAGS_use_function_calling,
419 value ==
"true" || value ==
"1");
423#ifdef YAZE_HTTP_API_ENABLED
425 if (absl::StartsWith(token,
"--http-port=") ||
426 absl::StartsWith(token,
"--http_port=")) {
427 size_t eq_pos = token.find(
'=');
429 int port = std::stoi(std::string(token.substr(eq_pos + 1)));
430 absl::SetFlag(&FLAGS_http_port, port);
432 result.
error =
"--http-port requires an integer value";
437 if (token ==
"--http-port" || token ==
"--http_port") {
439 result.
error =
"--http-port flag requires a value";
443 int port = std::stoi(std::string(argv[++i]));
444 absl::SetFlag(&FLAGS_http_port, port);
446 result.
error =
"--http-port requires an integer value";
452 if (absl::StartsWith(token,
"--http-host=") ||
453 absl::StartsWith(token,
"--http_host=")) {
454 size_t eq_pos = token.find(
'=');
455 absl::SetFlag(&FLAGS_http_host, std::string(token.substr(eq_pos + 1)));
458 if (token ==
"--http-host" || token ==
"--http_host") {
460 result.
error =
"--http-host flag requires a value";
463 absl::SetFlag(&FLAGS_http_host, std::string(argv[++i]));