]> git.stg.codes - stg.git/blobdiff - projects/sgconf/main.cpp
Ticket. The stgTime argument added in TariffChangeIsAllowed() function
[stg.git] / projects / sgconf / main.cpp
index 22e998f3561336c21cd2cfdf77bdaead854501e8..979081953464c40316b60c8b9708bef2098499a5 100644 (file)
@@ -25,6 +25,7 @@
 #include "users.h"
 #include "services.h"
 #include "corps.h"
+#include "info.h"
 
 #include "api_action.h"
 #include "options.h"
 #include <iostream>
 
 #include <cstdlib> // getenv
-#include <cstring> // basename
+#include <cstring> // str*
 
 #include <unistd.h> // access
+#include <libgen.h> // basename
 
 namespace
 {
@@ -119,7 +121,7 @@ return CONST_METHOD1_ADAPTER<C, A, R>(func, obj);
 
 void Version(const std::string & self)
 {
-std::cout << self << ", version: 2.0.0-alpha.\n";
+std::cout << self << ", version: 2.0.0.\n";
 }
 
 void ReadUserConfigFile(SGCONF::OPTION_BLOCK & block)
@@ -250,10 +252,15 @@ blocks.Add("General options")
 SGCONF::OPTION_BLOCK & block = blocks.Add("Connection options")
       .Add("s", "server", SGCONF::MakeParamAction(config.server, std::string("localhost"), "<address>"), "\t\thost to connect")
       .Add("p", "port", SGCONF::MakeParamAction(config.port, uint16_t(5555), "<port>"), "\t\tport to connect")
+      .Add("local-address", SGCONF::MakeParamAction(config.localAddress, std::string(""), "<address>"), "\tlocal address to bind")
+      .Add("local-port", SGCONF::MakeParamAction(config.localPort, uint16_t(0), "<port>"), "\t\tlocal port to bind")
       .Add("u", "username", SGCONF::MakeParamAction(config.userName, std::string("admin"), "<username>"), "\tadministrative login")
       .Add("w", "userpass", SGCONF::MakeParamAction(config.userPass, "<password>"), "\tpassword for the administrative login")
       .Add("a", "address", SGCONF::MakeParamAction(config, "<connection string>"), "connection params as a single string in format: <login>:<password>@<host>:<port>");
+blocks.Add("Debug options")
+      .Add("show-config", SGCONF::MakeParamAction(config.showConfig), "\tshow config and exit");
 SGCONF::AppendXMLOptionBlock(commands, blocks);
+SGCONF::AppendServerInfoBlock(commands, blocks);
 SGCONF::AppendAdminsOptionBlock(commands, blocks);
 SGCONF::AppendTariffsOptionBlock(commands, blocks);
 SGCONF::AppendUsersOptionBlock(commands, blocks);
@@ -299,7 +306,11 @@ else
 
 config = configOverride;
 
-std::cerr << "Config: " << config.Serialize() << std::endl;
+if (!config.showConfig.empty() && config.showConfig.data())
+    {
+    std::cout << config.Serialize() << std::endl;
+    return 0;
+    }
 return commands.Execute(config) ? 0 : -1;
 }
 catch (const std::exception& ex)