47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
|
|
#include <expected>
|
|
#include <string>
|
|
#include <cstring>
|
|
|
|
#include <uxlogger.hpp>
|
|
#include <uxclient.hpp>
|
|
#include <cliconfig.hpp>
|
|
|
|
#include <defines.hpp>
|
|
|
|
std::expected<void, std::string> Run(void) {
|
|
ClientConfig config;
|
|
std::string confdir(SRV_CONFDIR);
|
|
auto readRes = config.Read(confdir + "/" + "helmetcli.conf");
|
|
if (!readRes) {
|
|
return std::unexpected("Read config error: " + readRes.error());
|
|
}
|
|
auto validateRes = config.Validate();
|
|
if (!validateRes) {
|
|
return std::unexpected("Validate config error: " + validateRes.error());
|
|
}
|
|
auto servaddr = config.Servaddr();
|
|
auto servport = config.Servport();
|
|
auto localnets = config.Localnets();
|
|
|
|
UxClient client;
|
|
auto connectRes = client.Connect(servaddr, servport);
|
|
if (!connectRes) {
|
|
return std::unexpected(connectRes.error());
|
|
}
|
|
auto runRes = client.Run();
|
|
if (!runRes) {
|
|
return std::unexpected(runRes.error());
|
|
}
|
|
return {};
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
auto runRes = Run();
|
|
if (!runRes) {
|
|
uxlogger.Error(runRes.error());
|
|
return 1;
|
|
}
|
|
}
|
|
|