score-back/src/main.cpp
2026-03-11 16:38:50 +03:00

35 lines
1014 B
C++

#include "cloud_point_rpc/cli.hpp"
#include "cloud_point_rpc/config.hpp"
#include <fstream>
#include <glog/logging.h>
#include <iostream>
int main(int argc, char *argv[]) {
google::InitGoogleLogging(argv[0]);
FLAGS_logtostderr = 1;
std::string config_path = "config.yaml";
if (argc > 1) {
config_path = argv[1];
}
// Check if config file exists
std::ifstream f(config_path.c_str());
if (!f.good()) {
std::cerr << "Config file not found: " << config_path << std::endl;
std::cerr << "Please create config.yaml or provide path as argument."
<< std::endl;
return 1;
}
f.close();
try {
auto config = score::ConfigLoader::load(config_path);
return score::run_cli(std::cin, std::cout, config.server.ip,
config.server.port);
} catch (const std::exception &e) {
std::cerr << "Failed to start CLI: " << e.what() << std::endl;
return 1;
}
}