| 468 | } |
| 469 | |
| 470 | void covscript_main(int args_size, char *args[]) |
| 471 | { |
| 472 | if (args_size > 1) { |
| 473 | int index = covscript_args(args_size, args); |
| 474 | cs::current_process->import_path += cs::path_delimiter + cs::get_import_path(); |
| 475 | if (show_help_info) { |
| 476 | std::cout << "Usage: cs_dbg [options...] <FILE>\n" |
| 477 | << "Options:\n"; |
| 478 | std::cout << " Option Mnemonic Function\n"; |
| 479 | std::cout << " --help -h Show help infomation\n"; |
| 480 | std::cout << " --silent -s Close the command prompt\n"; |
| 481 | std::cout << " --version -v Show version infomation\n"; |
| 482 | std::cout << " --wait-before-exit -w Wait before process exit\n"; |
| 483 | std::cout << " --csym <FILE> -g <FILE> Read cSYM from file\n"; |
| 484 | std::cout << " --stack-resize <SIZE> -S <SIZE> Reset the size of runtime stack\n"; |
| 485 | std::cout << " --log-path <PATH> -l <PATH> Set the log path\n"; |
| 486 | std::cout << " --import-path <PATH> -i <PATH> Set the import path\n"; |
| 487 | std::cout << std::endl; |
| 488 | return; |
| 489 | } |
| 490 | else if (show_version_info) { |
| 491 | std::cout << "Covariant Script Programming Language Debugger\n"; |
| 492 | std::cout << "Version: " << cs::current_process->version << std::endl; |
| 493 | std::cout << cs::copyright_info << std::endl; |
| 494 | std::cout << "\nMetadata:\n"; |
| 495 | std::cout << " Import Path: " << cs::current_process->import_path << "\n"; |
| 496 | std::cout << " STD Version: " << cs::current_process->std_version << "\n"; |
| 497 | std::cout << " API Version: " << CS_GET_VERSION_STR(COVSCRIPT_API_VERSION) << "\n"; |
| 498 | std::cout << " ABI Version: " << CS_GET_VERSION_STR(COVSCRIPT_ABI_VERSION) << "\n"; |
| 499 | std::cout << " Runtime Env: " << COVSCRIPT_PLATFORM_NAME << "-" << COVSCRIPT_ARCH_NAME "\n"; |
| 500 | std::cout << " Compile Env: " << COVSCRIPT_COMPILER_NAME << "\n"; |
| 501 | std::cout << std::endl; |
| 502 | return; |
| 503 | } |
| 504 | if (index == args_size) |
| 505 | throw cs::fatal_error("no input file."); |
| 506 | if (args_size - index > 1) |
| 507 | throw cs::fatal_error("argument syntax error."); |
| 508 | path = cs::process_path(args[index]); |
| 509 | if (!cs_impl::file_system::exist(path) || cs_impl::file_system::is_dir(path) || |
| 510 | !cs_impl::file_system::can_read(path)) |
| 511 | throw cs::fatal_error("invalid input file."); |
| 512 | cs::prepend_import_path(path, cs::current_process); |
| 513 | if (!silent) { |
| 514 | std::cout << "Covariant Script Programming Language Debugger\nVersion: " |
| 515 | << cs::current_process->version << " [" << COVSCRIPT_COMPILER_NAME << " on " << COVSCRIPT_PLATFORM_NAME << "]\n" |
| 516 | "Copyright (C) 2017-2026 Michael Lee. All rights reserved.\n" |
| 517 | "Please visit <http://covscript.org.cn/> for more information." |
| 518 | << std::endl; |
| 519 | } |
| 520 | cs::current_process->on_process_exit.add_listener([](void *code) -> bool { |
| 521 | cs::current_process->exit_code = *static_cast<int *>(code); |
| 522 | throw cs::fatal_error("CS_DEBUGGER_EXIT"); }); |
| 523 | cs::current_process->on_process_sigint.add_listener([](void *) -> bool |
| 524 | { throw cs::fatal_error("CS_SIGINT"); }); |
| 525 | cs::current_process->on_process_sigint.add_listener([](void *) -> bool { |
| 526 | std::cin.clear(); |
| 527 | return false; }); |
no test coverage detected