@@ -260,7 +260,7 @@ void RunServer(std::optional<std::string> host, std::optional<int> port,
260260 CTL_WRN (" Require API key to access /v1/configs" );
261261 return false ;
262262 }
263-
263+
264264 // If API key is not set, skip validation
265265 if (api_keys.empty ()) {
266266 return true ;
@@ -383,6 +383,7 @@ void print_help() {
383383 " ~/cortexcpp)\n " ;
384384 std::cout << " --host Host name (default: 127.0.0.1)\n " ;
385385 std::cout << " --port Port number (default: 39281)\n " ;
386+ std::cout << " --api_configs Keys to acess API endpoints\n " ;
386387 std::cout << " --ignore_cout Ignore cout output\n " ;
387388 std::cout << " --loglevel Set log level\n " ;
388389
@@ -411,6 +412,7 @@ int main(int argc, char* argv[]) {
411412
412413 std::optional<std::string> server_host;
413414 std::optional<int > server_port;
415+ std::optional<std::string> api_keys;
414416 bool ignore_cout_log = false ;
415417#if defined(_WIN32)
416418 for (int i = 0 ; i < argc; i++) {
@@ -427,6 +429,8 @@ int main(int argc, char* argv[]) {
427429 server_host = cortex::wc::WstringToUtf8 (argv[i + 1 ]);
428430 } else if (command == L" --port" ) {
429431 server_port = std::stoi (argv[i + 1 ]);
432+ } else if (command == L" --api_keys" ) {
433+ api_keys = cortex::wc::WstringToUtf8 (argv[i + 1 ]);
430434 } else if (command == L" --ignore_cout" ) {
431435 ignore_cout_log = true ;
432436 } else if (command == L" --loglevel" ) {
@@ -447,6 +451,8 @@ int main(int argc, char* argv[]) {
447451 server_host = argv[i + 1 ];
448452 } else if (strcmp (argv[i], " --port" ) == 0 ) {
449453 server_port = std::stoi (argv[i + 1 ]);
454+ } else if (strcmp (argv[i], " --api_keys" ) == 0 ) {
455+ api_keys = argv[i + 1 ];
450456 } else if (strcmp (argv[i], " --ignore_cout" ) == 0 ) {
451457 ignore_cout_log = true ;
452458 } else if (strcmp (argv[i], " --loglevel" ) == 0 ) {
@@ -482,6 +488,15 @@ int main(int argc, char* argv[]) {
482488 }
483489 }
484490
491+ if (api_keys) {
492+ auto config = file_manager_utils::GetCortexConfig ();
493+ config.apiKeys = string_utils::SplitBy (*api_keys, " ," );
494+ auto result = file_manager_utils::UpdateCortexConfig (config);
495+ if (result.has_error ()) {
496+ CTL_ERR (result.error ());
497+ }
498+ }
499+
485500 // check if migration is needed
486501 if (auto res = cortex::migr::MigrationManager (
487502 cortex::db::Database::GetInstance ().db ())
0 commit comments