Commit 9ff9c6f4 authored by aligungr's avatar aligungr

CLI improvements

parent cc926d1a
...@@ -45,7 +45,7 @@ static std::set<int> FindProcesses() ...@@ -45,7 +45,7 @@ static std::set<int> FindProcesses()
return res; return res;
} }
static uint16_t DiscoverNode(const std::string &node) static uint16_t DiscoverNode(const std::string &node, int &skippedDueToVersion)
{ {
if (!io::Exists(cons::PROC_TABLE_DIR)) if (!io::Exists(cons::PROC_TABLE_DIR))
return 0; return 0;
...@@ -65,6 +65,7 @@ static uint16_t DiscoverNode(const std::string &node) ...@@ -65,6 +65,7 @@ static uint16_t DiscoverNode(const std::string &node)
} }
uint16_t found = 0; uint16_t found = 0;
skippedDueToVersion = 0;
for (auto &e : entries) for (auto &e : entries)
{ {
...@@ -79,8 +80,13 @@ static uint16_t DiscoverNode(const std::string &node) ...@@ -79,8 +80,13 @@ static uint16_t DiscoverNode(const std::string &node)
// If searching node exists in this file, extract port number from it. // If searching node exists in this file, extract port number from it.
for (auto &n : e.second.nodes) for (auto &n : e.second.nodes)
{ {
if (n == node) // TODO: version checking if (n == node)
found = e.second.port; {
if (e.second.major == cons::Major && e.second.minor == cons::Minor && e.second.patch == cons::Patch)
found = e.second.port;
else
skippedDueToVersion++;
}
} }
} }
...@@ -278,11 +284,12 @@ int main(int argc, char **argv) ...@@ -278,11 +284,12 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
uint16_t cmdPort; uint16_t cmdPort{};
int skippedDueToVersion{};
try try
{ {
cmdPort = DiscoverNode(g_options.nodeName); cmdPort = DiscoverNode(g_options.nodeName, skippedDueToVersion);
} }
catch (const std::runtime_error &e) catch (const std::runtime_error &e)
{ {
...@@ -292,6 +299,9 @@ int main(int argc, char **argv) ...@@ -292,6 +299,9 @@ int main(int argc, char **argv)
if (cmdPort == 0) if (cmdPort == 0)
{ {
std::cerr << "ERROR: No node found with name: " << g_options.nodeName << std::endl; std::cerr << "ERROR: No node found with name: " << g_options.nodeName << std::endl;
if (skippedDueToVersion > 0)
std::cerr << "WARNING: " << skippedDueToVersion
<< " node(s) skipped due to version mismatch between the node and the CLI" << std::endl;
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment